Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    1

    Unanswered: Datetime conversion

    I'm trying to calculate the amount of minutes between two datetime variables. I want the final result to be an integer, but I don't know the syntax to use in Informix.

    Any help is appreciated.

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    780
    Hi,

    Please test with function extend(datetime, year to minute).

    Gustavo.

  3. #3
    Join Date
    Aug 2004
    Posts
    10
    Hi,
    You can use INTERVAL datatype to calculate the time difference in the following way.

    DEFINE v1 DATETIME year to second;
    DEFINE v2 DATETIME year to second;

    DEFINE var1 INTERVAL hour to second

    LET var1 = v2 - v1

    With Regards,

    ID

  4. #4
    Join Date
    May 2004
    Location
    Barcelona, Spain
    Posts
    54

    interval to integer

    Quote Originally Posted by tachek
    I'm trying to calculate the amount of minutes between two datetime variables. I want the final result to be an integer, but I don't know the syntax to use in Informix.

    Any help is appreciated.
    I've never known how to convert an interval to an integer directly... however, this is the way I managed to do it:

    define dt1 datetime year to second;
    define dt2 datetime year to second;
    define iv1 interval minute(9) to minute;
    define number1 integer;

    let dt1 and dt2 get whatever values are needed;

    let iv1 = dt1 - dt2;
    let number1 = iv1::char(10);

    variable number1 gets the number of minutes passed between dt2 and dt1, which I assume you will like to use in some math expressions afterwards (if not, you could stick to the interval-type variable!)

    hope this helps

Posting Permissions

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