Function
STR_TO_DATE_MYSQL
is a SQL function used to convert a string into a date, compatible with the STR_TO_DATE
function in MySQL. This function can parse a string into a date type based on the specified format, making it very suitable for handling text fields that contain date information.
Syntax
Parameter Description
- date_string: The date string to be converted.
- format_string: The format of the date string. Refer to the MySQL official website for date string formats. This string defines how the date part of
date_string
should be parsed.
Return Result
This function returns a date type (DATE | TIMESTAMP) value, representing the successfully parsed date.
Example
Example 1: Basic usage
Example 2: Format as timestmap_ltz