Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3214290
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:02:36+00:00 2026-05-17T15:02:36+00:00

I have two tables where I was querying on a date column in each

  • 0

I have two tables where I was querying on a date column in each table.

In one case need to use the trunc() function on the date field to get values back, on the other I do not.

That is this works on table 1:

SELECT to_char( datecol1 ,'mm/dd/yyyy hh:mm:ss') 
FROM table1 where datecol1    =to_date('10/07/2010', 'mm/dd/yyyy');

But on table 2 the above syntax did not work and I needed the trunc(), such as:

SELECT to_char( datecol2 ,'mm/dd/yyyy hh:mm:ss') 
FROM table2 where trunc(datecol2) =to_date('10/07/2010', 'mm/dd/yyyy');

Three things to note:

  1. in querying table1 with to_char(datecol1 ,’mm/dd/yyyy hh:mm:ss’) it looks as if all the times are between 12:00 and 12:10, but values were inserted throughout the day
  2. when inserting records into table1 I just insert mm/dd/yyyy, no time
  3. when inserting records into table2 I inserted with the time

So can someone explain:

  • why the truncate is not needed on table1 but on table2?
  • why all values in table1 are between 12:00 and 12:10?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:02:37+00:00Added an answer on May 17, 2026 at 3:02 pm

    In table1 you have no ‘time-of-day’ component to the data, so a date should match – which is what you observed. But, you used mm for the formatting of the minute part of the time – but mm is month, not minute (mi). This is why you see times other than 12:00, and why they only range up to around 12:10 (you only have data for this year perhaps?)

    In table2, as you have a ‘time-of-day’ component to the data, you need to truncate that away in order to match a date-only value, which is what the to_date() function returns, given the format you have used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.