日期:2014-05-17  浏览次数:20458 次

.Net高手请进,关于table.select()的问题
table包含两个日期格式的列,我想要筛选出cl1和cl2两日期相差一个小时的所有的记录怎么写。
DATEDIFF()这个函数好像不能使用

------解决方案--------------------
with tb as
(
select '01.01.2013 16:01:00' as A, '01.01.2013 16:01:00' as B union all
select '01.01.2013 16:01:00' as A, '01.01.2013 16:03:00' as B union all
select '01.01.2013 16:01:00' as A, '01.01.2013 16:11:00' as B union all
select '01.01.2013 18:11:00' as A, '01.01.2013 16:21:00' as B
)
select * from tb
where ABS(DATEDIFF(MINUTE, A,B)) <= 60