Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Posts
    12

    Unanswered: getting duration between two datetime in seconds

    Hi,

    How can we get duration value between two datetimes in seconds.
    Is there any function like datediff ??

  2. #2
    Join Date
    Nov 2008
    Posts
    65
    Provided Answers: 1
    Again, cast is your best friend

    Code:
    select 
    ((current + 5 units day - current)::interval second(9) to second)
    ,((current + 5 units day - current)::interval second(9) to second)::char(10)::int8
    from systables
    where tabid=1
    First value is interval data type and second one is int8
    HTH

  3. #3
    Join Date
    Dec 2008
    Posts
    12
    Thank you for your answer.


    but why is the result 0, what is the first date and the second date here ?

  4. #4
    Join Date
    Nov 2008
    Posts
    65
    Provided Answers: 1
    First DATETIME is five days from current moment and second is current moment. So result should be 432.000 seconds (i.e. 5 * 24 * 60 * 60)

    This is my result:

    Code:
    root@ufedora:/home/informix/ids1150uc2# dbaccess sysmaster - <<END
    > select
    > ((current + 5 units day - current)::interval second(9) to second)
    > ,((current + 5 units day - current)::interval second(9) to second)::char(10)::int8
    > from systables
    > where tabid=1
    > END
    
    Database selected.
    
    
    
    (expression)         (expression)
    
        432000                 432000
    
    1 row(s) retrieved.
    
    
    
    Database closed.

Posting Permissions

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