Time Functions

The time functions of HCL OneDB™ 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

1  DATE ( non_date_expr )
1 
2.1 DAY
2.1 LAST_DAY
2.1 MONTH
2.1 QUARTER
2.1 WEEKDAY
2.1 YEAR
1 (
1 date/dtime_expr
1 )
1  EXTEND ( date/dtime_expr?  , first TO last )
1  MDY ( month , day , year )
1 
2.1  ADD_MONTHS ( date/dtime_expr , integer )
2.1  MONTHS_BETWEEN ( date/dtime_expr , date/dtime_expr )
2.1  NEXT_DAY ( date/dtime_expr , weekday )
2.1 
2.2.1  TO_CHAR (
2.2.2.1 date/dtime_expr
2.2.2.1 num_expr
2.2.1  TO_DATE ( char_expression
2.1?  , format_string
2.1 )

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