mysql关于时间查询 : 获取2017-06-14 17:33:03到现在的所有订单

来源:互联网 发布:数据结构 算法 c 编辑:程序博客网 时间:2024/05/20 04:10

获取2017-06-14 17:33:03到现在的所有订单
方法一:
SELECT createTime
from t_schedule_orders
where
DATEDIFF(createTime ,’2017-06-14 17:33:03’) >=0
and
DATEDIFF(createTime,NOW()) <=0

方法二:
SELECT createTime
from t_schedule_orders
where createTime>=’2017-06-14 17:33:03’

解读函数:
在mysql中函数DATEDIFF(a,b)的意思是: a-b的天数

select DATEDIFF(‘2017-06-14’,’2017-06-13’) AS 天数; 结果是1天
select DATEDIFF(‘2017-06-13’,’2017-06-14’) AS 天数; 结果是-1天