Skip to main content
Converts a string into a DATETIME value according to the specified format. If the conversion fails, NULL is returned. The format must be consistent with that described in date_format. This function is inverse to date_format.

Syntax

Parameters

str: the time expression you want to convert. It must be of the VARCHAR type. format: the format used to return the value. For the supported format, see date_format.

Return value

Returns a value of the DATETIME type. If format specifies a date, a DATE value is returned. NULL is returned if str or format is NULL.

Examples

Example 1: Convert the input into a DATETIME value.
Text
Example 2: Convert the input into a DATE value.
Text
Example 3: Convert the input “200442 Monday” into a DATE value.
Text

keyword

STR_TO_DATE,STR,TO,DATE