View previous topic :: View next topic |
Author |
Message |
rajat_gupta Beginner

Joined: 30 May 2007 Posts: 13 Topics: 5 Location: India
|
Posted: Thu Jun 19, 2008 12:56 pm Post subject: Comparing timestamp values in DB2 . |
|
|
Hi all,
Can anyone please help me out in comparing two Timestamp values in DB2.
I have a table having two fields.One is a 10 byte numeric field and one is a timestamp field.For one numeric field there can be multiple timestamp fields.
What I need to do is,
For a particular numeric field I need to find all the timestamp fields and then find the minimum difference(in hours) between any consecutive timestamp values for the same numeric value(in column1).
Is there any method or function in DB2/SQL thru which I can find the difference between two values of the same timestamp field in a table.
like timestampdiff().and how can I implement it.I tried a lot but was not able to find it anywhere.If anyone is having an idea of the SQL query then pls respond back.(I need to do it thru SQL only)
Thanks _________________ Rajat Gupta
when depressing thoughts seem to get you down
Put a smile on your face and thank God you're alive and still around. |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Thu Jun 19, 2008 2:10 pm Post subject: |
|
|
Code: |
((days(timestamp1) - days(timestamp2)) * 24) + hours(timestamp1 - timestamp2)
If the date will never differ then you can use
hours(timestamp1 - timestamp2)
|
It's all in DB2 SQL Reference. |
|
Back to top |
|
 |
|
|