By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,515 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

timestamp subtraction

P: n/a
Hi folks,
when subtracting 2 timestamps from each other the result is duration.
() But in DB2 the format is a bit funny:
lets say we have 59,5 seconds. If we have one second more, the result
is: 100,5. This mechanism works for seconds, minutes, hours, days.
months and years.
That would be OK if we always have the same number of days a month -
which does not reflect our calendar.
How many days has a month in the result? What is with leap years?
When I add 1 year to Feb. 29th this year, what is the result?
And when I subtract it from Feb. 29th this year, what is the result?
Is there a conversion to seconds and microseconds only?
I need it because I have calculate averages of runtimes...
Here also a result which is incorrect:

db2 "values ( timestamp('2008-02-28-12.00.00') + 1 year ,
timestamp('2008-02-29-12.00.00') + 1 year)"

1 2
-------------------------- --------------------------
2009-02-28-12.00.00.000000 2009-02-28-12.00.00.000000

1 record(s) selected.

It's clearly not the same when I add 1 year to two different dates...
Mar 19 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Is DAYS() what you are looking for?
http://publib.boulder.ibm.com/infoce.../r0000789.html

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 19 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.