I have to get data from an Oracle Database that are 2 weeks older from to-date.
Its a complex query and I have this condition in the where clause.
I have tried to use between. But in vain . I am sure I’m making some silly mistake in working out the between.
to_date(to_char(sysdate,'yyyy') || to_char(sgs.status_Date,'mmdd'),'yyyymmdd' )
between (trunc(sysdate)) and trunc(sysdate) - 14
Any help would be very much appreciated.
As @valex says, you need to swap the order of the expressions. As the documentation for the
BETWEENcondition says:Your version has
which is equivalent to
… which can never be true –
your_datewould have to simultaneously be after today, and before two weeks ago.