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')

posted @ 2016-03-17 10:14  大浪不惊涛  阅读(9076)  评论(0编辑  收藏  举报