1

I have a field, 'mydate' in my database which displays the date as a string like this

'8/1/2015 12:35:22 PM'

I am trying to convert this into a unix timestamp i have tried

cast(UNIX_TIMESTAMP('mydate',"yyyy-MM-dd HH:mm:ss.SSSS")) AS new_date

This has resulted in the query not completing completely. How can i convert this 'mydate' field into a unix timestamp.

2 Answers 2

2

Try something like this:

UNIX_TIMESTAMP(STR_TO_DATE(mydate, '%M %e %Y %h:%i%p'))
Sign up to request clarification or add additional context in comments.

Comments

1

You can simply check in mysql string format -

SELECT STR_TO_DATE('8/1/2015 11:35:22 PM','%d/%m/%Y %h:%i:%s %p');

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.