MySQL Forums
Forum List  »  General

Re: Why is STR_TO_DATE failing?
Posted by: Peter Brawley
Date: July 20, 2022 02:43PM

SELECT STR_TO_DATE( '5/7/1977 00:00:00',  '%m/%d/%Y %H:%i:%s' );  
+----------------------------------------------------------+
| STR_TO_DATE( '5/7/1977 00:00:00',  '%m/%d/%Y %H:%i:%s' ) |
+----------------------------------------------------------+
| 1977-05-07 00:00:00                                      |
+----------------------------------------------------------+

Change %h to %H.

Note that it's unsound and inefficient to store datetime values in MySQL as US-formatted varchars.

Options: ReplyQuote


Subject
Written By
Posted
Re: Why is STR_TO_DATE failing?
July 20, 2022 02:43PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.