Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    26

    Question Unanswered: How do i compare TIMESTAMP with DATE

    If i have the following table and TODAY is 11/Dec/2004 and time is 08hrs

    ----------------------------------------
    Sno | Timestamp_Column |
    ----------------------------------------
    1 | 2004-11-23 12:32:22 |
    2 | 2004-10-15 13:00:12 |
    3 | 2004-12-23 02:32:22 |
    4 | 2004-12-11 06:32:22 |
    5 | 2004-12-11 09:32:22 |
    ----------------------------------------

    I should get only those first 3 rows.


    i got the date part of the currenttime by converting the 'CURRENT TIMESTAMP' as below,

    DATE(CURRENT TIMESTAMP).

    and the compared it with the timestamp_column as follows.

    SELECT * from Vacation vac
    where
    (timestamp_column) >= DATE(CURRENT TIMESTAMP))

    As the two columns are of different datatypes, i am not able to compare them

    Is there any other way to do it.

    In simple i want all those rows dated yesterday and before.

    -gopidba

  2. #2
    Join Date
    May 2002
    Location
    General Deheza, Cba, Arg.
    Posts
    276
    hi,
    test this:
    SELECT * from Vacation vac
    where
    (timestamp_column) >= timestamp(DATE(CURRENT TIMESTAMP)) ,'00.00.00')

  3. #3
    Join Date
    May 2002
    Location
    General Deheza, Cba, Arg.
    Posts
    276
    or this:

    SELECT * from Vacation vac
    where
    date(timestamp_column) >= CURRENT DATE

  4. #4
    Join Date
    Nov 2004
    Posts
    26
    Thank you.

Posting Permissions

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