a.addtime>=to_date('2012-9-04 17:00:00','yyyy-mm-dd hh24:mi:ss') and a.addtime<= trunc(Sysdate)+1
我是查询昨天17:00的数据到当前时间的数据、我的问题是每天都要输入几号几号很烦、有什么办法 查询昨天的17:00的数据 不要在明天输入2012-09-5了
我是查询昨天17:00的数据到当前时间的数据、我的问题是每天都要输入几号几号很烦、有什么办法 查询昨天的17:00的数据 不要在明天输入2012-09-5了
怎么查询啊昨天的17:00的数据到今天、不手动写时间
sysdate-1为昨天
trunc(sysdate-1)为昨天凌晨0:00
trunc(sysdate-1)+20/24 为昨天晚上8点
select trunc(sysdate-1)+20/24 from dual;这个可以解决你的问题了
addtime>=trunc(sysdate-1)+17/24
and addtime<= trunc(Sysdate)+1 order by addtime desc
完整的语句 查询出来是今天的
select * From hz_dd
where
addtime>=trunc(sysdate-1)+17/24 --昨天17点 不行减2 或3 试试
and addtime<= trunc(Sysdate) --今天
order by addtime desc
我么有oracle数据库,无法测试啊,谅解
SQL怎么写between('2012-09-04 17:00:00') and GETDATE()
between convert(varchar(10),getdate()-1,120)+' 17:00:00' and GETDATE()