Get end of Month based on year and Month

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

ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Why are you making this so complicated; the leap year logic is built into the DataStage date processing, so (as mentioned earlier), add one month to your date and then subtract a day and -voila- DataStage gives you a correct date, every time.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

You made me write the code for you but test it if it works in every scenario (it expects input data in yyyymmdd or yyyymm format).

Code: Select all

datefromdayssince(-1,if InLink.DateString[5,2] =12 then InLink.DateString[1,4]+1:"-01-01" else InLink.DateString[1,4]:"-":right("00":InLink.DateString[5,2]+1,2):"-01")
This you could have done yourself if you would have thought about it after getting many leads in earlier posts and in that case you could have learned the basics.

You may have to do null handling if input contains null.
Last edited by priyadarshikunal on Wed Mar 03, 2010 12:17 pm, edited 1 time in total.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... just exactly how did they "make you" write the code for them? Did they find out where you live? :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

sometimes its annoying to make people understand the logic when they just want the code (not your lecture :wink: ). Just a reflex, nothing serious. I don't think they hired MI6 to hunt me down :wink:
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Its very simple in Unix

Code: Select all

echo $(cal 12 2008) | awk ' { print $NF } '
You are the creator of your destiny - Swami Vivekananda
Post Reply