0

I have table column with datatype as VARCHAR(255) and value in it as "Dec 31 1969 18:00:00". I need to convert this value in date format like Y-m-d H:i:s i.e. 1969-12-31 18:00:00 Tried with the solution using STR_TO_DATE, but is not working anymore. I tried like -

SELECT STR_TO_DATE('Dec 31 1969 18:00:00','%M %d,%Y %h:%i:%s') 

BUt, this returns NULL.

Any help is appreciated. Thank you.

0

1 Answer 1

1
  • Remove the comma (,) from the format.
  • %M is the full name of the month, not abbreviated, like %b.
  • %h is 12-hour hours value. Use %H or use %T for the whole time part.

Try something like this:

SELECT STR_TO_DATE('Dec 31 1969 18:00:00','%b %d %Y %T') 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.