简体   繁体   中英

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'

Use DATE_FORMAT() and STR_TO_DATE()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM