Background documentationDate Function (date_function) Locate this document in the navigation structure

 

A date function (date_function) is a function that is applied to date or time stamp values or supplies a date or time stamp value as a result.

Structure

Syntax Syntax

  1. <date_function> ::=
      ADDDATE(<date_or_timestamp_expression>,<expression>)
    | DATEDIFF(<date_or_timestamp_expression>,<date_or_timestamp_expression>)
    | DAYNAME(<date_or_timestamp_expression>)
    | DAYOFMONTH(<date_or_timestamp_expression>)
    | DAYOFWEEK(<date_or_timestamp_expression>)
    | DAYOFYEAR(<date_or_timestamp_expression>)
    | MAKEDATE(<expression>,<expression>)
    | MONTHNAME(<date_or_timestamp_expression>)
    | SUBDATE(<date_or_timestamp_expression>)
    | WEEKOFYEAR(<date_or_timestamp_expression>)
    
    <date_or_timestamp_expression> ::=
      <expression>
End of the code.
Examples

SQL Tutorial, Date and Time Calculations

Explanation

When used in a function, the argument date_or_timestamp_expression must supply a date, a time stamp or an alphanumeric value that matches the current date or time stamp format. Date and time values can be specified in a variety of date and time formats (ISO, USA, EUR, JIS, INTERNAL). Although the Gregorian calendar was not introduced until 1582, it can also be applied to date functions that use dates prior to that year. This means that every year is assumed to have either 365 or 366 days.

More Information

Functions: Overview