The query below does not work
missing right parenthesis
but you know what I need to get, so how I can get it to work?
how should I write it!
SELECT sysdate,
(sysdate + interval (to_char(sysdate, 'YYYY') - 2011) YEAR) as tt
FROM dual;
I was thinking of this solution
SELECT sysdate,
add_months(sysdate,12*(to_char(sysdate, 'YYYY') - 2011))
FROM dual;
is it a correct approach?
Thanks
This should get you to what you are looking for:
Note the appending of the “-0” is necessary, since there is no Year interval, it has years and months (the “-0” indicates 0 months).
It should also be noted that this will cause problems on leap day, since Feb 29 doesn’t exist next year.
I would solve this problem by converting your years to months (multiply by 12) and using add_months:
Which on leap day will return 2/28/2013 for tt.