读书人

.Net关于table.select()的有关问题

发布时间: 2013-08-25 10:49:56 作者: rapoo

.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

读书人网 >SQL Server

热点推荐