jerrygarciuh
jerrygarciuh

Reputation: 21988

Formatting strings into dates in mySQL

I am migrating an Access db to mySQL. I am receiving the tables as CSVs and using Excel to drop and format some columns. The dates are coming to me as m/d/yyyy and go as far back as 1702. Since Excel brilliantly won't format any date before 1900 I am going to have to transform them some other way. Now it would be super simple to write a PHP script to iterate over rows and use date('Y-m-d', strtotime($date)) but I was wondering if there was a function or functions in mySQL that would be the equivalent?

Upvotes: 1

Views: 86

Answers (1)

user510365
user510365

Reputation: 196

Try the STR_TO_DATE function. e.g.

SELECT STR_TO_DATE('4/1/1960', '%m/%d/%Y');

Upvotes: 3

Related Questions