数据库怎么样查询指定日期部分的差值代码

数据库怎么样查询指定日期部分的差值代码
2025-04-12 11:32:29
推荐回答(2个)
回答(1):

with t(d) as (select '2014-1-21 11:13:10'
union all select '2014-1-10 00:00:00'),
t1(d) as (select cast(d as datetime) from t)
select * from t1
where d between dateadd(ss, -1000, getdate()) and dateadd(ss, 1000, getdate())

回答(2):

试试