How to get previous month in the sequence/Basic language

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
chandu123
Premium Member
Premium Member
Posts: 40
Joined: Mon Sep 12, 2016 1:26 pm

How to get previous month in the sequence/Basic language

Post by chandu123 »

I am passing parameters to a Job activity in the sequence. I have two parameters current month (YYYYMM format) and previous month (YYYYMM) format. Is there a way to derive previous month from the current month (preferably in the Value Expression section of the Job Activity)?

Please suggest.
HB
JRodriguez
Premium Member
Premium Member
Posts: 425
Joined: Sat Nov 19, 2005 9:26 am
Location: New York City
Contact:

Post by JRodriguez »

...and you have the current month, right? Then it will be a matter of date arithmetic. Resolved the first day of the current month and substract 1 day to it.
OConv(Iconv(CurrMonth:"01" ,"D YMD[4,2,2]") - 1), "D YM[4,2]")

I would suggest to do this in a user variable and then pass the user variable to the job's parameter instead of doing this logic directly on the value expression for the paraneter
Julio Rodriguez
ETL Developer by choice

"Sure we have lots of reasons for being rude - But no excuses
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Take a look at the date Transforms supplied in every project. There are useful, pre-defined Transforms for things like MONTH.FIRST and MONTH.LAST, which can recognize a MONTH.TAG structure such as you are using.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply