Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
vijigobi wrote: |
Hi,
I would like to know how to get difference of timestamp in HH:MM:SS format in a SQL query.
Consider 2 timestamp columns in a table
PROG_START_TS and PROG_ENDE_TS.
I would like to select difference between these timestamps in a readable format.
Thanks
Vivek. |
DB2 will return the difference of two times as a decimal(6,0) value , hhmmss.
time(prog_ende_ts) - time(prog_start_ts)
For timestamps the difference is a decimal(26,6) value, yyyymmddhhmmss.sssss
prog_ende_ts - prog_start_ts
If you use just the time of the timestamp you may will end up with an incorrect answer if the dates are different. |
|