Add/Subtract N months from Input date YYYY-MM-DD

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
chandramouliravi
Participant
Posts: 18
Joined: Sat Nov 06, 2010 3:35 am

Add/Subtract N months from Input date YYYY-MM-DD

Post by chandramouliravi »

Hi all,

I need Add/Subtract N months (say 6 months) to Input date.
I want to do it using DS Functions rather than SQL.

Input date format: YYYY-MM-DD
Output date format: YYYY-MM-DD

This is what i have tried
1) DateFromDaysSince(-1, stringtodate(right(0:MonthFromDate(DSLink4.Datee),2):'-':'01':'-': YearFromDate(DSLink4.Datee),"%mm-%dd-%yyyy"))
But its for subtracting Days rather than Months.
2) I have seen few SQL options.
3) I have saw that in V8.5, Below function may work which is not in V8.1.
So i could not use
DateOffsetByComponents(%basedate%,%yearoffset%,%monthoffset%,%dayoffset%)


Could you please let me know the solution.
Thanks,
Mouli
synsog
Premium Member
Premium Member
Posts: 232
Joined: Sun Aug 01, 2010 11:01 pm
Location: Pune

Post by synsog »

Post Reply