Search code examples
dateinformixextend

What is the difference between CURRENT and TODAY in Informix


I am junior in informix and I am struggling with some date calculations. I have this code snippet in my source:

LET dtRefDate = TODAY;

IF extend( CURRENT, hour to hour ) BETWEEN '06' AND '23'  THEN LET
   dtRefDate = TODAY+1;
END IF;

Can anybody explain me please what does extend function do? and what is the difference between CURRENT and TODAY? I didn't comprehend the difference from IBM official documentation. Thank you


Solution

  • TODAY returns a DATE value, CURRENT returns a DATETIME (YEAR TO FRACTION (3)) value.

    EXTEND is used to extract individual parts of a DATE or DATETIME value.

    Look at this examples:

    > select CURRENT from table(set{1});
    (expression)
    2019-09-29 10:07:12.000
    1 row(s) retrieved.
    
    > select TODAY from table(set{1});
    (expression)
    09/29/2019
    1 row(s) retrieved.
    
    > select extend(TODAY,year to year) from table(set{1});
    (expression)
    2019
    1 row(s) retrieved.
    
    > select extend(TODAY,month to day) from table(set{1});
    (expression)
    09-29
    1 row(s) retrieved.
    
    > select extend(CURRENT,hour to minute) from table(set{1});
    (expression)
    10:08
    1 row(s) retrieved.
    
    >