timestamp subtraction

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • stefan.albert

    timestamp subtraction

    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...
  • Serge Rielau

    #2
    Re: timestamp subtraction

    Is DAYS() what you are looking for?


    Cheers
    Serge

    --
    Serge Rielau
    DB2 Solutions Development
    IBM Toronto Lab

    Comment

    Working...