Oracle of dating Lycos sexdating
Working with negative values can cause unexpected results.
Coding should be: begin if Sourcedate = last_day(Sourcedate) then Sourcedate := Sourcedate - 1; Sourcedate := add_months(Sourcedate, Num Months); if Sourcedate ^= last_day(Sourcedate) then Sourcedate := Sourcedate 1; end if; else Sourcedate := add_months(Sourcedate, Num Months); end if; -- Sourcedate :- Sourcedate - 1 ( the original quest ) end hi tom my question is that i change the particular date in year. select to_char( add_months(to_date('', 'DD-MM-YYYY'),12),'year') from dual; result is TO_CHAR(ADD_MONT ---------------- two thousand one but my requirement is 2001.
Therefore, it could also apply to cases where the input "day of month" is the last day of the input month and is less than or equal to the result "day of month" which is the case in question here.
What you need is an expression or better yet a "Function" (imagine that) that simulates a modified Add_Months Function, one where the above definition is changed to simply "If the resulting month has fewer days than the day component of date, then the result is the last day of the resulting month." Then, subtract one day from whatever the result is.
First impressions to get the next year might be to add 365 days...
Tom I know adding 365 days is not right and I intended to explain to original poster (who wanted to jump from 28th Feb 2007 to 28th Feb 2008 ) was not calendar-friendly , rather plain arithmetic.By the way, the part before subtracting one day would also be the same definition as a VB/VBA Date Add("m", Num Months Inc, Source Date) call.