The syntax checker says that this is OK. But when I preview the report I get 33 compilation errors. Not sure what I am doing wrong.
{IIF(Month(Today) = 1, (DateSerial(Year(Today) - 2, 12, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 2, (DateSerial(Year(Today) - 1, 1, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 3, (DateSerial(Year(Today) - 1, 2, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 4, (DateSerial(Year(Today) - 1, 3, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 5, (DateSerial(Year(Today) - 1, 4, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 6, (DateSerial(Year(Today) - 1, 5, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 7, (DateSerial(Year(Today) - 1, 6, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 8, (DateSerial(Year(Today) - 1, 7, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 9, (DateSerial(Year(Today) - 1, 8, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 10, (DateSerial(Year(Today) - 1, 9, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 11, (DateSerial(Year(Today) - 1, 10, 1)).ToString("MM.dd.yyyy"),
IIF(Month(Today) = 12, (DateSerial(Year(Today) - 1, 11, 1)).ToString("MM.dd.yyyy"),""))))))))))))}
The error of compilation
The error of compilation is found in the 'Text' property of the 'Text_14' component:
'Month' is not declared. It may be inaccessible due to its protection level.
Nested IIF statement fail
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Nested IIF statement fail
Hello,
Please try to use the following expression instead your iif():
{DateSerial((Today.AddYears(-1).AddMonths(-1)).Year, (Today.AddYears(-1).AddMonths(-1)).Month, 1)}
Thank you.
Please try to use the following expression instead your iif():
{DateSerial((Today.AddYears(-1).AddMonths(-1)).Year, (Today.AddYears(-1).AddMonths(-1)).Month, 1)}
Thank you.