View previous topic :: View next topic
|
Author |
Message |
sreelekshmi
New User
Joined: 16 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
Hi,
I need to get the difference between two time stamps using SQL Query.Can anyone explain me how I can write that SQL query ?
this is urgent.
Thanks n regards,
Sree... |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Sree,
First of all please read forum rules.
We are not here to do ur homework so please do not specify urgent & all
Well Please find below query
Code: |
SELECT TIMESTAMP('2007-07-23-08.09.07.821084') - TIMESTAMP('2007-07-23-08.08.07.821084') |
FROM SYSIBM.SYSDUMMY1;
U can also move timestamp in to some hostvariable & use the query to identify the difference. |
|
Back to top |
|
|
sandeep1dimri
New User
Joined: 30 Oct 2006 Posts: 76
|
|
|
|
Hi
Similary if one need to get difference between dates,hour, sec or microosec form time stamp can be achieived from Db2 standard functions.
for example to get various values from time stamp.
SELECT CURRENT TIMESTAMP,
YEAR (CURRENT TIMESTAMP),
MONTH (CURRENT TIMESTAMP),
DAY (CURRENT TIMESTAMP),
HOUR (CURRENT TIMESTAMP),
MINUTE (CURRENT TIMESTAMP),
SECOND (CURRENT TIMESTAMP),
MICROSECOND (CURRENT TIMESTAMP)
FROM SYSIBM.SYSDUMMY1;
So respective diff can be done on any of above values.
Hope it will help.
sandeep |
|
Back to top |
|
|
sreelekshmi
New User
Joined: 16 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
I am really sorry,Only I meant is to get a quick help if possible.
Thanks for the reply
Sree..
guptae wrote: |
Hi Sree,
First of all please read forum rules.
We are not here to do ur homework so please do not specify urgent & all
Well Please find below query
Code: |
SELECT TIMESTAMP('2007-07-23-08.09.07.821084') - TIMESTAMP('2007-07-23-08.08.07.821084') |
FROM SYSIBM.SYSDUMMY1;
U can also move timestamp in to some hostvariable & use the query to identify the difference. |
|
|
Back to top |
|
|
|