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 > Doubt in Informix db query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-08, 07:42
smaniguru smaniguru is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
Doubt in Informix db query

Hi All,

I have a column(ex:Received_date) of type datetime. I want to find the number of hours in between the current datetime and Received_date.
Thanks in Advance.
Reply With Quote
  #2 (permalink)  
Old 11-18-08, 02:56
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
What's your format of datetime?(which time units it contains-(year,month, ...)
?
Reply With Quote
  #3 (permalink)  
Old 11-18-08, 08:03
smaniguru smaniguru is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
Format: DATETIME YEAR TO FRACTION(5) (eg., 2008-11-18 07:01:45.000)

Need a query will give the result like the below example,

Received_date: 2008-11-17 07:01:45.000
Current datetime: 2008-11-18 07:01:45.000
Result(Difference in hours) : 24 hrs

Last edited by smaniguru; 11-18-08 at 08:11.
Reply With Quote
  #4 (permalink)  
Old 11-24-08, 13:57
ibm.ids ibm.ids is offline
Registered User
 
Join Date: Nov 2008
Posts: 64
Something like this:
create table test_date_time(
dt1 datetime year to fraction(5),
dt2 datetime year to fraction(5)
);
insert into test_date_time values("2008-11-17 07:01:45.000", "2008-11-18 07:01:45.000");

select (dt2 - dt1)::interval hour to hour from test_date_time;

drop table test_date_time;
As you can see, result from DATETIME - DATETIME is INTERVAL and you can CAST it on precision you want.
HTH
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