Skip to main content

TO_DATE

Descriptionโ€‹

Date conversion function, used to convert date time (DATETIME) to date type (DATE), that is, remove the time part and keep only the date (YYYY-MM-DD)

Syntaxโ€‹

TO_DATE(<datetime_value>)

Required parameterโ€‹

ParameterDescription
datetime_valueDATETIME type date-time

Exampleโ€‹

Convert 2020-02-02 00:00:00 to 2020-02-02

select to_date("2020-02-02 00:00:00");
+--------------------------------+
| to_date('2020-02-02 00:00:00') |
+--------------------------------+
| 2020-02-02 |
+--------------------------------+

Enter to send ยท Shift+Enter for a new line