If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How do i compare TIMESTAMP with DATE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-11-04, 02:58
gopidba gopidba is offline
Registered User
 
Join Date: Nov 2004
Posts: 26
Question 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
Reply With Quote
  #2 (permalink)  
Old 12-11-04, 09:13
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
hi,
test this:
SELECT * from Vacation vac
where
(timestamp_column) >= timestamp(DATE(CURRENT TIMESTAMP)) ,'00.00.00')
Reply With Quote
  #3 (permalink)  
Old 12-11-04, 09:15
achiola achiola is offline
Registered User
 
Join Date: May 2002
Location: General Deheza, Cba, Arg.
Posts: 273
or this:

SELECT * from Vacation vac
where
date(timestamp_column) >= CURRENT DATE
Reply With Quote
  #4 (permalink)  
Old 12-13-04, 00:20
gopidba gopidba is offline
Registered User
 
Join Date: Nov 2004
Posts: 26
Thank you.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On