cancel
Showing results for 
Search instead for 
Did you mean: 

Last 3 month month year

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member211423
Active Participant
0 Kudos

Hi Ashwin,

Please follow following steps:

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


Former Member
0 Kudos

Hi,

Thanks for replying....

  Here i'm getting in place of "04" as "4" and "2014" as "2,014".

So after concatenation  like 4.2,014 is not equal to 04.2014.

so please help....

former_member211423
Active Participant
0 Kudos

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

Answers (1)

Answers (1)

sateesh_kumar1
Active Contributor
0 Kudos

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")