last day from date

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
smohd1338
Premium Member
Premium Member
Posts: 28
Joined: Fri Aug 03, 2012 1:09 pm

last day from date

Post by smohd1338 »

i get yyyymmdd format date , i need output as yyyymmdd(but dd has to be last day of month 'mm', is there a direct funtion to pull last day of any month,

For Example: Input filed = 20130814, then output should = 20130831
sameer
smohd1338
Premium Member
Premium Member
Posts: 28
Joined: Fri Aug 03, 2012 1:09 pm

Post by smohd1338 »

i foud, looks like daysinmonth should work
sameer
smohd1338
Premium Member
Premium Member
Posts: 28
Joined: Fri Aug 03, 2012 1:09 pm

Post by smohd1338 »

there is no daysinmonth function in 8.1? how shall i write vthe loic without going into if then else
sameer
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... you could always play the old game of setting the date to the first day of the next month and then subtracting one day from it. :wink:

You could also build yourself a "DaysInMonth" routine... only four possible answers after all with some pretty well-known rules for the only one that is a variable.
-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 »

May be you can start from here.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Field("31|28|31|30|31|30|31|31|30|31|30|31", "|", MonthFromDate(InLink.TheDate), 1) 
is a quick way (ignoring leap years) to get the day number of the last day of the month. You can then build the date from components. Use an If..Then..Else derivation for the list to set the last day of February to 29 if it is a leap year.
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