date query for previous months
i am trying to get previous months rows from a table.the table have orderid and oreder created date fields.
if i run today i need to get all rows with a created date january
so whats the problem
where date between 1st jan and 31st jan
sorry i should have been clear .
yes currently thats what i have in place and trying to aviod hard coded dates
like "where trunc(order_created_date ) between '01-JAN-2010' and '31-JAN-2010'
then i have to change every month mnaually and i do not want sysdate -30 which still forces manual entry to change based on the month to i am trying to skip that too
so my cron runs on feburary 1st and gets all january data and when it runs on march first it gets all february data and so on..
thanks for your help
If you do this you can get any month you want, just subtract a different number. You can also create a function based index if you want.
where trunc(order_created_date, 'MM' ) =
ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -1)
this space intentionally left blank
thank you ..i see where i went wrong
Click Here to Expand Forum to Full Width