Vladimir Zaguzin
Vladimir Zaguzin

Reputation: 303

oracle : find dates between 2 dates with sysdate

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

Answers (3)

Abdullah Ahsan
Abdullah Ahsan

Reputation: 107

Try this:

select * from myTable where trunc(calendar_date) >= trunc(sysdate-14) and calendar_date <= trunc(sysdate).

Upvotes: 1

Needle file
Needle file

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

Hasan Alizada
Hasan Alizada

Reputation: 591

Try this:

select * from myTable where trunc(calendar_date) between trunc(sysdate) and trunc(sysdate-14) 

Upvotes: 0

Related Questions