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 we can calculate different between two time with HH:MM:SS format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-06, 14:34
M_RAS M_RAS is offline
Registered User
 
Join Date: Sep 2003
Location: canada
Posts: 230
How we can calculate different between two time with HH:MM:SS format

I am working with db2v8.2.2 aix 5.2

is there any function I caculate different between to times.

Thank for your help
Reply With Quote
  #2 (permalink)  
Old 02-09-06, 02:42
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
time

you mean this :
db2admin:/cygdrive/c/workdir: db2 "select * from tim"

COL1 COL2
-------- --------
08:40:37 05:40:37

1 record(s) selected.

db2admin:/cygdrive/c/workdir: db2 "select col1-col2 from tim"

1
--------
30000,

1 record(s) selected.
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #3 (permalink)  
Old 02-09-06, 08:52
M_RAS M_RAS is offline
Registered User
 
Join Date: Sep 2003
Location: canada
Posts: 230
Quote:
Originally Posted by przytula
you mean this :
db2admin:/cygdrive/c/workdir: db2 "select * from tim"

COL1 COL2
-------- --------
08:40:37 05:40:37

1 record(s) selected.

db2admin:/cygdrive/c/workdir: db2 "select col1-col2 from tim"

1
--------
30000,

1 record(s) selected.
Thank you for your help, could you please tell me what is 30000, is it second?
but 3 hours difference can not be 30000 seconds?
Reply With Quote
  #4 (permalink)  
Old 02-09-06, 08:55
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
30000
means
03 hours 00 minutes 00 seconds
Reply With Quote
  #5 (permalink)  
Old 02-09-06, 09:44
M_RAS M_RAS is offline
Registered User
 
Join Date: Sep 2003
Location: canada
Posts: 230
Quote:
Originally Posted by umayer
30000
means
03 hours 00 minutes 00 seconds
Oh.... Thank you for your help.
Reply With Quote
  #6 (permalink)  
Old 02-09-06, 10:21
ihendr ihendr is offline
Registered User
 
Join Date: Mar 2005
Posts: 7
timestampdiff

you can also use the timestampdiff function wich can show the difference from 'Fractions of a second' up to 'Years'.

example: diff of one day in seconds
db2 => values timestampdiff(2,char((current timestamp + 1 day) - current timestamp ))

1
-----------
86400

1 record(s) selected.


regards,
I.
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