0

SCENARIO

I am trying to migrate data and currently my date value is just a string in the format of Jun 28, 2001 aka MMM DD, YYYY format. I need to convert them into a DateTime object such that it will be displayed as 2001-06-28T00:00:00

QUESTION

I have read about STR_TO_DATE function but I am still having trouble understanding it.

Please help, thank you!

2 Answers 2

2

You could try using '%b %d, %Y'

select str_to_date('Jun 28, 2001', '%b %d, %Y' )

and eventually formatting as

 select date_format(str_to_date('Jun 28, 2001', '%b %d, %Y' ), '%Y-%m-%dT%T')
Sign up to request clarification or add additional context in comments.

Comments

1

Use this line :-

select str_to_date('Jun 28, 2001', '%b %d, %Y' )

And go through this link to understand :-

https://www.w3schools.com/sql/func_mysql_str_to_date.asp

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.