Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Posts
    58

    Unanswered: date less than today

    Hi,

    How do we select all columns with date less than today? The d/b has DATE format. ex: 12/11/2003 5:02:19

    Thank you

  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    date/time format has nothing to do with it.

    all you do is specify the date/time you want.

    so:

    select * from table_name where date_column < trunc(sysdate);

    or

    select * from table_name where date_column < to_date('03182004 00','MMDDYYYY HH24');
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Mar 2004
    Posts
    17

    Re: date less than today

    Originally posted by chatguy2020
    Hi,

    How do we select all columns with date less than today? The d/b has DATE format. ex: 12/11/2003 5:02:19

    Thank you
    SELECT <COLUMN_NAME> FROM < TABLE_NAME>
    WHERE
    <COLUMN_NAME> < (SELECT SYSDATE FROM DUAL);

  4. #4
    Join Date
    Nov 2003
    Location
    India
    Posts
    114

    Re: date less than today

    The second answer is not correct. You have to take into account exact timestamps when you are working with dates.

    So the query should be

    select <date_column> from <table_name> where trunc(<date_column>) < trunc(sysdate)

  5. #5
    Join Date
    Jul 2003
    Posts
    2,296
    didn't I take care of this in the first post???
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •