Minus 62 days from Current_Date but need 1st day of the mont

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
imfarhan
Participant
Posts: 53
Joined: Tue Jul 24, 2012 9:34 am

Minus 62 days from Current_Date but need 1st day of the mont

Post by imfarhan »

I'm using following code to get minus -62days of the current date :

Code: Select all

Ereplace(Oconv(iconv(DSJobStartDate,"D-YMD")-62,"D-YMD[4,2,2]"),"-","")
The output I'm getting is
pPeriodStartDate= 20131115

20131115 -62days

Now I need '01' instead of '15' , meaning 1st day of the month so it should be like 20131101 instead of 20131115 or
Replace the 'dd' value to constant value '01'

Many thanks in advance

Kind regards
Farhan
Farhan Syed
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

may be just take a substring and add the constant value

Code: Select all

Ereplace(Oconv(iconv(DSJobStartDate,"D-YMD")-62,"D-YMD[4,2,2]"),"-","")[1,6]:"01"
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
imfarhan
Participant
Posts: 53
Joined: Tue Jul 24, 2012 9:34 am

Post by imfarhan »

Thanks a lot Priyadarshikuna
Its work perfectly fine.

Kind regards
Farhan
Farhan Syed
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A bit overly complex but, as you say, it works. I'd use Iconv(), arithmetic, then the MONTH.FIRST transform.
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