Tuesday, February 15, 2011

Query Record for last week in oracle

below query will tell the date between which you want to extract record.

select (next_day(TRUNC(sysdate),'Mon')-14), (next_day(TRUNC(sysdate),'SUN')-7) from dual

so your query will be:

Column_Name between (next_day(TRUNC(sysdate),'Mon')-14) and (next_day(TRUNC(sysdate),'SUN')-7)

Note: you can adjust your week by changing the value in day (Mon,Sat.........)

No comments :

Post a Comment