Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Unanswered: 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.

  2. #2
    Join Date
    Aug 2005
    Posts
    140
    What's your format of datetime?(which time units it contains-(year,month, ...)
    ?

  3. #3
    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 09:11.

  4. #4
    Join Date
    Nov 2008
    Posts
    65
    Provided Answers: 1
    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

Posting Permissions

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