Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Location
    canada
    Posts
    230

    Unanswered: How we can calculate different between two time with HH:MM:SS format

    I am working with db2v8.2.2 aix 5.2

    is there any function I caculate different between to times.

    Thank for your help

  2. #2
    Join Date
    Nov 2004
    Posts
    374

    time

    you mean this :
    db2admin:/cygdrive/c/workdir: db2 "select * from tim"

    COL1 COL2
    -------- --------
    08:40:37 05:40:37

    1 record(s) selected.

    db2admin:/cygdrive/c/workdir: db2 "select col1-col2 from tim"

    1
    --------
    30000,

    1 record(s) selected.
    Best Regards, Guy Przytula
    DB2/ORA/SQL Services
    DB2 DBA & Advanced DBA Certified
    DB2 Dprop Certified
    http://users.skynet.be/przytula/dbss.html

  3. #3
    Join Date
    Sep 2003
    Location
    canada
    Posts
    230
    Quote Originally Posted by przytula
    you mean this :
    db2admin:/cygdrive/c/workdir: db2 "select * from tim"

    COL1 COL2
    -------- --------
    08:40:37 05:40:37

    1 record(s) selected.

    db2admin:/cygdrive/c/workdir: db2 "select col1-col2 from tim"

    1
    --------
    30000,

    1 record(s) selected.
    Thank you for your help, could you please tell me what is 30000, is it second?
    but 3 hours difference can not be 30000 seconds?

  4. #4
    Join Date
    Dec 2005
    Posts
    273
    30000
    means
    03 hours 00 minutes 00 seconds

  5. #5
    Join Date
    Sep 2003
    Location
    canada
    Posts
    230
    Quote Originally Posted by umayer
    30000
    means
    03 hours 00 minutes 00 seconds
    Oh.... Thank you for your help.

  6. #6
    Join Date
    Mar 2005
    Posts
    7

    timestampdiff

    you can also use the timestampdiff function wich can show the difference from 'Fractions of a second' up to 'Years'.

    example: diff of one day in seconds
    db2 => values timestampdiff(2,char((current timestamp + 1 day) - current timestamp ))

    1
    -----------
    86400

    1 record(s) selected.


    regards,
    I.

Posting Permissions

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