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 > operations on current timestamp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-04, 18:36
ranjithm ranjithm is offline
Registered User
 
Join Date: Feb 2004
Posts: 5
Question operations on current timestamp

Is there a way to do operations on the special register - current timestamp? The goal is to be able to use it as a criteria in a where clause . for e.g. lets say i have a table with createtimestamp as a column. In Oracle, I can fetch records created in the past 1 hour with a where clause of "createtimestamp > (sysdate - 1/24)" or for the past 1 day as "createtimestamp > (sysdate - 1)". In Db2, my understanding was that current timestamp was the equivalent of sysdate but I am not able to get operations such as subtraction to work on it.
Reply With Quote
  #2 (permalink)  
Old 02-25-04, 19:00
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Select * from table_name
where createtimestamp + 1 hour > current timestamp
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 02-25-04, 19:06
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: operations on current timestamp

You should find this and many more datetime functions and operators you can use with current date in SQL Reference



HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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