Page 1 of 1

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

Posted: Thu Jan 16, 2014 6:26 am
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

Posted: Thu Jan 16, 2014 6:40 am
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"

Posted: Thu Jan 16, 2014 6:55 am
by imfarhan
Thanks a lot Priyadarshikuna
Its work perfectly fine.

Kind regards
Farhan

Posted: Thu Jan 16, 2014 3:48 pm
by ray.wurlod
A bit overly complex but, as you say, it works. I'd use Iconv(), arithmetic, then the MONTH.FIRST transform.