mysql - SQL date format convert? [dd.mm.yy to YYYY-MM-DD] -
is there mysql function convert date format dd.mm.yy yyyy-mm-dd?
for example, 03.09.13 -> 2013-09-03
.
since input string in form 03.09.13
, i'll assume (since today september 3, 2013) it's dd-mm-yy. can convert date using str_to_date
:
str_to_date(myval, '%d.%m.%y')
then can format string using date_format
:
date_format(str_to_date(myval, '%d.%m.%y'), '%y-%m-%d')
note year %y
(lowercase "y") in str_to_date
, %y
(uppercase "y") in date_format
. lowercase version two-digit years , uppercase four-digit years.
Comments
Post a Comment