作者:pengwei8751150 | 来源:互联网 | 2023-05-19 09:16
例子:selectcount(*)fromtablewhereDATEDIFF([second],2016-09-1800:00:18,2016-09-1800:0
例子:
select count(*) from table where DATEDIFF ([second], '2016-09-18 00:00:18', '2016-09-18 00:00:19') > 0
说明
select DATEDIFF(day, time1 , time2) 对应示例语句如下
select DATEDIFF(day, '2016-07-23 0:41:18', '2016-07-23 23:41:18')
time1 > time2 为负数;
time1 < time2 为正数;
[day] :只会比较 2016-07-23 忽略 0:41:18' 其他同理
以下分别:
年: SELECT DATEDIFF([year],time1 , time2)
月: SELECT DATEDIFF([month], time1 , time2)
天: SELECT DATEDIFF([day], time1 , time2)
小时: SELECT DATEDIFF([hour], time1 , time2)
秒: SELECT DATEDIFF([second], time1 , time2)