Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Posts
    42

    Question Unanswered: formating the result of timestamp2-timestamp1

    Hello,

    I want to know the time elapsed between 2 timestamps. Simple enough, I do timestamp2-timestamp1 and I get my result.

    Now I'd like to format the result. Here is an example :

    2008-06-05-12.06.23.216000 - 2008-06-05-11.12.45.670000 returns 5337,546000.

    How can I format the result to have a readable value, something like seconds and milliseconds?

    EDIT : I just found the TIMESTAMPDIFF function in which I can choose the output in seconds, minutes, hours, etc. Better than nothing.

    Thanks.

    JFS.
    Last edited by svrider; 06-05-08 at 15:25.

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Quote Originally Posted by svrider
    2008-06-05-12.06.23.216000 - 2008-06-05-11.12.45.670000 returns 5337,546000
    The six digits after the decimal points are of course milliseconds, but to the left of the decimal point you'll have to read "37" as the seconds, "53" as the minutes, etc.: each group of 2 digits is a next time level (hours, days, months, years).
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    This article described alternative way for TIMESTAMPDIFF.
    DB2 Basics: Fun with Dates and Times
    http://www.ibm.com/developerworks/db.../0211yip3.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •