Breezy
Breezy

Reputation: 21

How do i search mysql between two dates?

Currently my dates are formatted like 01/01/2012. how do i update mysql records to set date from 01/01/2013 to 2013-01-01 without having to do each date individually?

update table set date='2012-01-01' where date='01/01/2012'

Upvotes: 0

Views: 53

Answers (1)

John Conde
John Conde

Reputation: 219794

Use DATE_FORMAT() and STR_TO_DATE()

UPDATE
    tablename
SET
    date = DATE_FORMAT(STR_TO_DATE(date, "%d/%m/%Y"), "%Y-%m-%d")

Upvotes: 2

Related Questions