Page 1 of 1

Transformation help required in Transformer

Posted: Tue Apr 12, 2016 1:21 pm
by harman
Hi,

i need below transformation help in transformer

LAST_DAY(Current_Date - 1 MONTH)

please help me on this.

Posted: Tue Apr 12, 2016 1:53 pm
by chulett
So... in other words... you need to find the last day of the previous month?

Posted: Tue Apr 12, 2016 2:08 pm
by harman
Yes chulett last day of previous month

Posted: Tue Apr 12, 2016 2:08 pm
by qt_ky
Please clarify what is meant by minus 1 month... is it meant as "previous month" or subtract 30 days, etc.?

Posted: Tue Apr 12, 2016 2:11 pm
by harman
minus 1 month means previous month

values
LAST_DAY(Current_Date - 1 MONTH) i ran this statement in db2 and got the result
2016-03-31 same i need through datatstage

Posted: Tue Apr 12, 2016 6:38 pm
by Mike
That's pretty straight forward these days with a couple of parallel transform functions: one to subtract a month and another to get the number of days in a month.

What I don't remember though... in what version was the DaysInMonth function added? It's relatively new and I don't remember if it existed in version 9.

Mike

Posted: Tue Apr 12, 2016 6:59 pm
by ray.wurlod
Last day of previous month is a one day (-1 day) offset from the first day of the current month.

Therefore the easiest solution is to build the first day of the current month by subtracting the current day number in the month from the current date.

Functions are DateFromDaysSince() and MonthDayFromDate(). The rest is simple arithmetic.

Posted: Wed Apr 13, 2016 9:41 am
by harman
Thanks Ray for reply.

can you please help me by providing the transformation i can use in transformer

Posted: Wed Apr 13, 2016 5:09 pm
by ray.wurlod
I provided you with the needed functions - please experiment with these as a learning experience.

I prefer to teach you to fish rather than to give you a fish.
If I give you a fish that's consulting, and you pay for my time.