Year to date report - how do I get dates without hard coding a year?
957056Aug 21 2012 — edited Aug 22 2012I am writing a monthly report that will run for example on Sept1 but want to extract data for Jan 1, 2012 thru Aug 31, 2012. But also need to consider when I run report on Jan 1, 2013 for all of 2012. I know I could use the add_months(sysdate,-1) to get previous month but then will still have issues running on Jan 2013 for the year.
SELECT data
FROM tables
WHERE data_date between start-date (which would be Jan 1, 2012 but also when I run on Jan 1 2013 for previous year)
and last_day(add_months(sysdate, -1)
Thanks in advance
Jackie