Date and time functions

Db2 supports date and time functions that are defined through vendor escape clauses.

The following rules apply to these functions:
  • Arguments denoted as timestamp_exp can be the name of a column, the result of another scalar function, or a time, date, or timestamp literal.
  • Arguments denoted as date_exp can be the name of a column, the result of another scalar function, or a date or timestamp literal, where the underlying data type can be character based, or date or timestamp based.
  • Arguments denoted as time_exp can be the name of a column, the result of another scalar function, or a time or timestamp literal, where the underlying data types can be character based, or time or timestamp based.
CURDATE()
Returns the current date as a date value.
CURTIME()
Returns the current local time as a time value.
DAYOFMONTH( date_exp )
Returns the day of the month in date_exp as an integer value in the range of 1-31.
HOUR( time_exp )
Returns the hour in time_exp as an integer value in the range of 0-23.
MINUTE( time_exp )
Returns the minute in time_exp as integer value in the range of 0-59.
MONTH( date_exp )
Returns the month in date_exp as an integer value in the range of 1-12.
NOW()
Returns the current date and time as a timestamp value.
SECOND( time_exp )
Returns the second in time_exp as an integer value in the range of 0-59.