Former Member

Last 3 month month year

Hi Experts,

My dateformat of my field is MM.YYYY,

so in the prompt for end date i used formula

userresponse("Enter last date:") as in prompt statement

Now i want the last 3 months date

e.g; last month =12.2014

then i want 11.2014,10.2014,09.2014

Thanks.

Ashwin

10|10000 characters needed characters exceeded

Jan 02, 2015 at 06:43 AM

Hi Ashwin,

Create variable Month

1. Month=   ToNumber(Substr(( userresponse("Enter last date:"));0;2))

**This will Give you Month Number.

2. Month-1 = If([Month] =1) Then 12 Else([Month]-1)

**This will give last month number

3. Month-2 = If([Month] =1) Then 11 ElseIf ([Month] =2) Then 12 Else ([Month]-2)

**This will give last to last month number

4. Month-3 = If([Month] =1) Then 10 ElseIf ([Month] =2) Then 11 ElseIf ([Month] =3) Then 12 Else ([Month]-3)

**This will give last to last to last month number

Similarly you can find year and later concatenate both.

Hope it helps!

Let me know if I dint get your requirement correct.

Regards

Sheetal Sharma

10|10000 characters needed characters exceeded
• SHEETAL SHARMA Former Member

Hi Ashwin,

1. Use Format number function to remove "," in Year as below:

Year = Formatnumber([Year Calculated];"####")

**This will give result as YYYY instead of Y,YYY

2. For Month

Month = Formatnumber([Month Calculated];"####")

Sufix  = If(Length([Month])<2 ;0)

3. Final Formula=Concatenation([Sufix];[Month];".";[Year])

02.2015

Hope it helps!!

Regards

Sheetal Sharma

• Jan 02, 2015 at 10:50 AM

Hi Aswin ,

V_Month =userresponse("Enter last date")

Previous month

=FormatDate(RelativeDate( ToDate([V_Month];"M.yyyy");-1);"M.yyyy")

Previous to Previous

=FormatDate(RelativeDate( ToDate(FormatDate(RelativeDate( ToDate([V_Month];"M.yyyy");-1);"M.yyyy");"M.yyyy");-1);"M.yyyy")