say_eed
say_eed

Reputation: 19

Oracle Query Condition

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

Answers (2)

Gordon Linoff
Gordon Linoff

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

Pelin
Pelin

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

Related Questions