Reputation: 303
I need to get a list or rows where date is between dates based on current date;
i'm trying to get it like this
select * from myTable where calendar_date between trunc(sysdate) and trunc(sysdate-14)
and it returns nothing, while
select * from myTable where calendar_date = trunc(sysdate)
and
select * from myTable where calendar_date = trunc(sysdate-15)
would return rows with that days what am I missing ?
Upvotes: 0
Views: 79
Reputation: 107
Try this:
select * from myTable where trunc(calendar_date) >= trunc(sysdate-14) and calendar_date <= trunc(sysdate).
Upvotes: 1
Reputation: 518
select * from myTable where calendar_date between trunc(sysdate) and trunc(sysdate-14)
change order in between. first less date second greater date
select * from myTable where calendar_date between trunc(sysdate-14) and trunc(sysdate)
Upvotes: 4
Reputation: 591
Try this:
select * from myTable where trunc(calendar_date) between trunc(sysdate) and trunc(sysdate-14)
Upvotes: 0