Course
Simulator
More
Premium
Log in
Function Reference
MySQL
PostgreSQL
Functions
STR_TO_DATE
STR_TO_DATE
Returns date and time based on string and string format
MySQL 8.1
STR_TO_DATE
(
string
,
format
)
string
Source string with date
format
Date string format
Format component
Description
%M
Full month name(January...December)
%b
Short name of the month (Jan...Dec)
%m
The numeric value of the month (01...12)
%d
Numeric value of the day of the month (00...31)
%W
Weekday name in full(Sunday...Saturday)
%a
Weekday name in short (Sun...Sat)
%j
Day of the year (001..366)
%Y
Year as a numeric (4-digit value)
%y
Year as a numeric (2-digit value)
%H
Hour with leading zero in 24-hour format (00...23)
%h
Hour with leading zero in 12-hour format (01...12)
%i
Minutes (00...59)
%s
Seconds(00...59)
%f
Microseconds (000000...999999)
%p
AM or РМ
Examples
MySQL 8.1
SELECT
STR_TO_DATE
(
'November 13, 1998'
,
'%M %d, %Y'
)