简体   繁体   中英

Date conversion from string

I have run a query

select STR_TO_DATE('March-2008', '%M-%Y')

I got output:

February, 29 2008 00:00:00

Why it is not March, 01 2008 00:00:00

mysql 5.5 sqlfiddle

Thanks @splash58 and @wchiquito( answering from you comments );

Unspecified date or time parts have a value of 0 , so incompletely specified values in str produce a result with some or all parts set to 0

See STR_TO_DATE

Query:

select day(STR_TO_DATE('March-2008', '%M-%Y'))

OutPut:

0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM