STR_TO_DATE_DATE()

Overview

Parses a string argument using the supplied format and returns a DATE value.

USAGE

STR_TO_DATE_DATE(string, format)

Argument Name

Description

string

The string to parse

format

A specification of how to parse the data out of the string

DETAILS

STR_TO_DATE_DATE() is a date-time function that converts a string into a date value based on a restricted parsing order specified in the format argument.

Spaces specified in the string and the format are matched loosely, while other non-escape characters in the format string are required to exist in the source string.

A NULL is returned if any argument is NULL.

Option

Description

%a

Abbreviated weekday name in the current locale

%b

Abbreviated month name in the current locale

%c

Month number in 1 or 2 digits

%D

Day number with English suffix "st", "nd", "rd", or "th"

%d

Day number in 2 digits

%e

Day number in 1 or 2 digits

%j

Numeric day of the year in 3 digits (001-366)

%M

Full month name in the current locale

%m

Month number in 2 digits

%U

Week number (00-53) starting on Sunday

%u

Week number (00-53) starting on Monday

%V

Week number (01-53) starting on Sunday

%v

Week number (01-53) starting on Monday

%W

Full weekday name in current locale

%w

Day of the week (Sunday is 0)

%X

Year with 4 digits according to %V

%x

Year with 4 digits according to %v

%Y

Year with 4 digits

%y

Year with 2 digits

%%

A literal % character

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT STR_TO_DATE_DATE('01,02,2020', '%d,%m,%Y') AS result;
+------------+
| result     |
+------------+
| 2020-02-01 |
+------------+
SELECT STR_TO_DATE_DATE('September 1, 2019 11:30',
                   '%M %d,%Y %h:%i') AS result;
+------------+
| result     |
+------------+
| 2019-09-01 |
+------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES