用sql语言怎么写,从数据库中提取一个时间与当前时间做差,将差值小于某个数的条目提取出来

2025-03-03 10:38:33
推荐回答(5个)
回答1:

access 中有一个时间差的函数可以直接用,可以用datediff这个函数

回答2:

oracle中没有datediff()函数如果是用oracle的话 使用这个来计算时间差
精确到秒:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60)精确到毫秒:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60 * 60)

回答3:

  select …………from table ……… where datediff(ss,starttime,endtime)  精确到秒

回答4:

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())

回答5:

oracle写法:SELECT * FROM 表 t WHERE t.fcjsj>to_date('2013-01-04 00:00:00','yyyy-MM-dd HH24:MI:ss')