Time Functions

The time functions of Informix® accept DATE or DATETIME arguments, or character representation of a DATE or DATETIME value. They typically return DATE or DATETIME values, or convert information that they extract from DATE or DATETIME values into character strings or integers.

See also the descriptions of the ROUND and TRUNC functions, which can change the precision of DATE or DATETIME values, in the section Algebraic Functions.

Time Functions

{ DATE(non_date_expr ) | { DAY | LAST_DAY | MONTH | QUARTER | WEEKDAY | YEAR } (date/dtime_expr) | EXTEND(date/dtime_expr [ ,firstTO last ] ) | MDY(month ,day,year) | { ADD_MONTHS(date/dtime_expr ,integer) | MONTHS_BETWEEN(date/dtime_expr ,date/dtime_expr) | NEXT_DAY(date/dtime_expr ,weekday) | { TO_CHAR( { date/dtime_expr | num_expr } | TO_DATE(char_expression } [ ,format_string ] ) } }

Element Description Restrictions Syntax
char _expression Expression to be converted to a DATE or DATETIME value Must be a literal, host variable, expression, or column of a character data type Expression
date/dtime _expr Expression that returns a DATE or DATETIME value Can be host variable, expression, column, or constant. Expression
day Expression that returns the number of a day of the month Must return integer > 0 but no greater than the number of days in the specified month Expression
first Largest time unit in the result. If you omit first and last, the default first is YEAR. Must be a DATETIME qualifier keyword that specifies a time unit no smaller than last DATETIME Field Qualifier
format_string String that contains a format mask for the first argument Must be a character data type that specifies a valid format. Can be a column, host variable, expression, or constant Quoted String
integer Expression that specifies a whole number of months Must evaluate to positive or negative integer Expression
last Smallest time unit in the result Must be a DATETIME qualifier keyword that specifies a time unit no smaller than first DATETIME Field Qualifier
month Expression that represents the number of the month Must evaluate to an integer in the range from 1 to 12, inclusive Expression
non _date_expr Expression that represents a value to be converted to a DATE data type Typically an expression that returns a CHAR, DATETIME, or INTEGER value that can be converted to a DATE data type Expression
num_expr Expression that evaluates to a real number Must return a numeric data type Expression
weekday Abbreviated name of a day of the week A character data type containing a valid abbreviation for a day of the week Quoted String
year Number expression that represents a year Must evaluate to a 4-digit integer. You cannot use a 2-digit abbreviation. Expression