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

  • SEARCH
  • Home
  • 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 8154587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:24:08+00:00 2026-06-06T16:24:08+00:00

I have a table structure having a EMP_DATE column as below ID EMP_DATE —-

  • 0

I have a table structure having a EMP_DATE column as below

 ID       EMP_DATE
----    -----------
5400     14-FEB-2012

and i have inserted records into the table as below

INSERT INTO TEST_DATE VALUES(5400,SYSDATE);

After inserting records while i am trying to fetch the records of those who has EMP_DATE
as SYSDATE its giving no rows selected.
For time being let the SYSDATE be ’01-JUL-2012`

 SELECT * FROM TEST_DATE WHERE EMP_DATE = SYSDATE;
                (OR)
 SELECT * FROM TESt_DATE WHERE EMP_DATE = '01-JUL-2012';

i was not able figure out any solution .
Any suggestions would be helpful .

  • 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-06-06T16:24:10+00:00Added an answer on June 6, 2026 at 4:24 pm

    The main problem is that a date includes hours, minutes and seconds, which you’re not allowing for. If you want everything for a single day you can use the trunc function in order to get this:

    SELECT * FROM TEST_DATE WHERE trunc(EMP_DATE) = trunc(SYSDATE);
    

    By default trunc removes the time portion of a date, when operating on a date column. I would normally recommend a functional index on trunc(emp_date) in order to optimize this query. Something like:

    create index i_test_date on test_date(trunc(emp_date));
    

    I’ve built a little SQL Fiddle to demonstrate this.

    There is an additional problem; though Oracle does support ANSI date literals your second query is wrong. Always, explicitly convert to a string to a date using the to_date function.

    SELECT * FROM TEST_DATE WHERE EMP_DATE = to_date('01-07-2012','dd-mm-yyyy');
    

    I’ve used the mm datetime format model instead of mon as there’s no guarantee that JUL will always mean July; it depends on your NLS parameters, what “date language” your particular database or session is using. A datetime format model is how you tell the database the format of whatever string you’re passing it to be converted into a date.


    If you’re interested the ANSI syntax for your second query would be:

    SELECT * FROM TESt_DATE WHERE trunc(EMP_DATE) = DATE '2012-07-01'
    

    It must be in this format (YYYY-MM-DD) to work.

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

Sidebar

Related Questions

I have a table with below structure. I am not having control over changing
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have created a table in MSSQL having following structure - **Table Name -
i have a table with 3 columns. It is having duplicate on column 2
I'm having difficulty with this problem. I have a table with this structure: OrderID
I have the following table structure and I want a turn the query into
I have two Tables say Table-A and Table-B having same table structure (means number
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table structure: ous.txt 1452 1793 out.txt 36796 14997 ouw.txt 478 4247 3
I have this table structure on a SQL Server 2008 R2 database: CREATE TABLE

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.