AL icon indicating copy to clipboard operation
AL copied to clipboard

Extention error: Not supporting Date type in Case statement.

Open Nagaraju17 opened this issue 8 years ago • 3 comments

We have written the following code in C/AL and converted into AL.

Case DateFilter of 0D : Statement1; 12252018D: Statement12; Else Statement3; END;

       When i compile the code in VS code environment i am getting below error.

error CS0151: A switch expression or case label must be a bool, char, string, integral, enum, or corresponding nullable type

Nagaraju17 avatar Feb 08 '18 14:02 Nagaraju17

Is variable DateFilter really of data type Date, not Text?

NKarolak avatar Feb 08 '18 14:02 NKarolak

HI NKarolak,

Yes, it is data type of Date only.

Nagaraju17 avatar Feb 09 '18 06:02 Nagaraju17

Hi @Nagaraju17 ! This should work. A Date literal is of the form: yyyymmdd followed by the letter D: For example: 20180101D -> 2018, January, 1st 20001201D -> 2000, December, 1st

If you use a value that is outside the range of a valid date: 20002501D -> 2000, month 25, 1st

you will get an error. Constant value '20002501D' is outside the range for a Date

We will add more documentation about the format of Date, Time and DateTime literals.

atoader avatar Mar 23 '18 10:03 atoader