Reputation: 561
what I'm trying to accomplish is to subtract 1 month from user given date variable. My code in where conditions is as following:
CONDITION >= to_char(add_months('&datum_od', 1), 'dd.mm.yyyy')
I am getting "ORA-1843: not a valid month" error.
Could you guys please help me out here?
Upvotes: 0
Views: 331
Reputation: 44941
to_date(CONDITION,'dd.mm.yyyy') >= add_months(to_date('&datum_od','dd.mm.yyyy'), -1)
Please notice
Upvotes: 1
Reputation: 4818
Error suggest that you ave incorrect format of date. Probably caused by &datum_od
is in other format than NLS date.
Try:
CONDITION >= to_char(add_months(to_date(&datum_od,'yyyy-mm-dd'), 1), 'dd.mm.yyyy')
And pass your variable &datum_od
in format specified.
Next thing is why do you do >=
comparison on strings not on dates? To_char
seems wrong here.
Upvotes: 1