MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Comparing timestamp values in DB2 .

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
rajat_gupta
Beginner


Joined: 30 May 2007
Posts: 13
Topics: 5
Location: India

PostPosted: Thu Jun 19, 2008 12:56 pm    Post subject: Comparing timestamp values in DB2 . Reply with quote

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
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Thu Jun 19, 2008 2:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group