DATE( )

This MySQL function returns the date from a given string, value, or expression that is submitted in a date or datetime format.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

DATE(expression)

Explanation

This function returns the date from a given string, value, or expression that is submitted in a date or datetime format. This function is available as of version 4.1.1 of MySQL.

Examples

SELECT appointment, DATE(appointment)
FROM appointments
WHERE client_id = '8639' LIMIT 1;

+---------------------+-------------------+
| appointment         | DATE(appointment) |
+---------------------+-------------------+
| 2008-01-11 14:11:43 | 2008-01-11        |
+---------------------+-------------------+

In this SQL statement, the value of the appointment column, which is a DATETIME type column, is shown first. The second field is the date extracted by the function from the same column and row.