Reputation: 19
I am working on a report in oracle, and the query is automated in every month to generate a monthly report. And i need to run the report for the month f September 2018 manually. But i didn't understand the below condition, how to update it to get the September month report.
AND (( to_char(i.c_date_closed+1/6,'MM/YYYY')
=to_char(add_months(sysdate+1/6,-1),'MM/YYYY')
or to_char(i.date_entered,'MM/YYYY') =
to_char(add_months(sysdate+1/6,-1),'MM/YYYY')))
Upvotes: 0
Views: 44
Reputation: 1271003
Wouldn't just do this?
where i.c_date_closed >= date '2018-09-01' and
i.c_date_closed < date '2018-10-01'
Upvotes: 1
Reputation: 966
You can check year and month separately. It should work like this:
AND (to_char(i.c_date_closed, 'Month') =to_char(sysdate,'Month')
or to_char(i.date_entered,'Month') = to_char(sysdate,'Month'))
and ( to_char(sysdate,'yyyy') = to_char(sysdate,'yyyy')
or to_char(sysdate,'yyyy') = to_char(sysdate,'yyyy'))
Upvotes: 0