This tutorial explains how to use the MySQL DATE function with syntax and examples.
The MySQL DATE function extracts the date value from a date or datetime expression.
The syntax for the DATE function in MySQL is:
DATE( expression )
The date or datetime value from which the date should be extracted.
The DATE function can be used in the following versions of MySQL:
Let's look at some MySQL DATE function examples and explore how to use the DATE function in MySQL.
For example:
mysql> SELECT DATE('2014-02-14');
Output: '2014-02-14'
mysql> SELECT DATE('2014-02-14 18:20:19');
Output: '2014-02-14'
mysql> SELECT DATE('2014-02-15 06:18:01.000001');
Output: '2014-02-15'
mysql> SELECT DATE('The date is 2014-02-14');
Output: NULL
mysql> SELECT DATE(NULL);
Output: NULL