0

I have expression on Text Box that after StartDate selected It type some text. It working normally, except 1 month of the years is selected It throws an error. I need to specify something like that IF month = 1 then years = -1 month = 12. For now my expression looks like:

= MonthName(Right(Parameters!StartDate.Value-1,2).ToString()) + " - " + Left((Parameters!StartDate.Value - 100).ToString(),4)

And StartDate parameter is in format like: 201401, 201402, 201403, 201404, etc I can't get correct syntax for It.

Pedram
  • 6,256
  • 10
  • 65
  • 87

1 Answers1

0

Try this: =Monthname(Dateadd(DateInterval.Month,-2, cdate(Left(Parameters!StartDate.Value,4)&"-"&right(Parameters!StartDate.Value,2)&"-01")).Month,False)

Aftab Ansari
  • 926
  • 9
  • 17
  • Thank you for an answer, but I dont need to specify IFF or Switch? It should make -1 for every month, but If It Is 1 month (January) Ir should convert to something like that: `years = -1 and month = 12` For example if StartDate is `201401` It should be converted to `201312` and If StarDate is `201405` It should be converted to (as for now Is) `201404` – Stanislovas Kalašnikovas Mar 05 '15 at 09:26
  • Your previous method worked as well! This one `= MonthName(Right(Parameters!StartDate.Value,2),False).ToString()....` And how about to make the same with `MonthName(Right(Parameters!StartDate.Value-2,2).ToString()` ? Here the same problem If I choose 2 month of years (February) for example `201402` – Stanislovas Kalašnikovas Mar 05 '15 at 09:48
  • Instead of doing Parameters!StartDate.Value-2, first convert your date value in proper date format and then use date methods to get the desired output. – Aftab Ansari Mar 05 '15 at 10:11
  • Your last update returning only month, without years. – Stanislovas Kalašnikovas Mar 05 '15 at 11:43
  • give me some details about your requirement. – Aftab Ansari Mar 05 '15 at 12:25