我有以下示例:
select * from my_table
where date between ('19-06-2014 00:00:00,000000000 EUROPE/BUCHAREST') and ('19-06-2014 23:59:59,000000000 EUROPE/BUCHAREST'
如果我运行此查询,则返回正确的值。我需要的是这样的事情:
select * from my_table
where date between ('today - 2DAYS ') and ('today - 1DAY')
你知道我怎么能做到这一点吗?
答案 0 :(得分:1)
尝试以下解决方案:
- 一天的结果
select * from my_table where date between sysdate - 2 and sysdate - 1
- 如果您希望从当天开始:
select * from my_table where date between trunc(sysdate) - 2 and trunc(sysdate) - 1
FYI - sysdate引用当前日期,并且子数值将按日计算。如果你想减去12小时,你应该减去0.5。