MySQL中日期與字符串相互轉換,並進行日期比較查詢


技術交流群:233513714

 

1、日期無需轉換查詢(日期在數據庫中的類型為字符串)

select * from day where dateTime > '2016-03-15'

2、使用date_format

select * from day where date_format(dateTime,'%Y-%m-%d') > '2016-03-15'

3、日期轉換還可以使用str_to_date()

select str_to_date(dateTime,'%Y-%m-%d %H:%i:%s')


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM