MySQL DATE() Function

In MySQL, the DATE() function extracts and returns the date part from a datetime value.

DATE() Syntax

Here is the syntax of MySQL DATE() function:

DATE(expr)

Parameters

expr
Required. A date or datetime value or expression.

Return value

The MySQL DATE() function returns the date part of a date or datetime expression.

If the specified expression is not a valid date or datetime, the function will return NULL.

If the argument is NULL, the function will return NULL.

DATE() Examples

Here are some examples of the DATE() function.

SELECT
    DATE('2022-02-28'),
    DATE('2022-02-28 10:10:10'),
    DATE(NOW()),
    DATE('2022-02-30'),
    DATE('Not A Date'),
    DATE(NULL)\G
         DATE('2022-02-28'): 2022-02-28
DATE('2022-02-28 10:10:10'): 2022-02-28
                DATE(NOW()): 2022-04-13
         DATE('2022-02-30'): NULL
         DATE('Not A Date'): NULL
                 DATE(NULL): NULL