HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
MySQL Functions : Return a date based on a string and a format
The STR_TO_DATE() function returns a date based on a string and a format.
STR_TO_DATE(string, format)
Parameter | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
string | Required. The string to be formatted to a date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format | Required. The format to use. Can be one or a
combination of the following
values:
|
Works in: | From MySQL 4.0 |
---|
Return a date based on a string and a format:
SELECT STR_TO_DATE("August,5,2017", "%M %e %Y");
Return a date based on a string and a format:
SELECT STR_TO_DATE("Monday, August 14, 2017", "%W %M %e %Y");
Return a date based on a string and a format:
SELECT STR_TO_DATE("2017,8,14 10,40,10", "%Y,%m,%d %h,%i,%s");