If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > getting duration between two datetime in seconds

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-08, 12:23
denizcaglar denizcaglar is offline
Registered User
 
Join Date: Dec 2008
Posts: 12
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 ??
Reply With Quote
  #2 (permalink)  
Old 12-24-08, 17:21
ibm.ids ibm.ids is offline
Registered User
 
Join Date: Nov 2008
Posts: 64
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
Reply With Quote
  #3 (permalink)  
Old 12-25-08, 05:02
denizcaglar denizcaglar is offline
Registered User
 
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 ?
Reply With Quote
  #4 (permalink)  
Old 12-25-08, 11:42
ibm.ids ibm.ids is offline
Registered User
 
Join Date: Nov 2008
Posts: 64
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On