How to validate a string date in Mendix?

I'm running into an issue when trying to validate an incoming string date when using parsedatetime.  Using parseDateTimeUTC("32-11-2020”, 'dd-MM-yyyy', empty) does not result into empty but in 02-12-2020. This way I can not validate imported string values containing a date. How do you validate string dates when importing them to a datetime value in Mendix? Do I have to get a java function?   (I now use the “creative” construction getting a substring to catch the "32” and then comparing it with the day part of the resulting DateTime variable ("2") ) => Mendix 8.15.2
2 answers

That is either the result of an odd implementation choice or an oversight. It is consistent in adding the days into the next month, even into the next year. It also subtracts days into the previous month, even negative numbers get processed. Some tests on show these results:

The last example even adds one hour for daylight saving time.

And it takes in big numbers too:

Your “creative” solution is actually very good. As far as I can see it covers all unexpected results.


I would consider this a bug. Did some testing. In 8.10 it would give a fault when parsing this string (I did not have 8.9 on my machine). But in later versions it indeed gave this result. I also tested it in Mx7.23.7 and it gave the same result. It seems you found a very peculiar bug here. FIle a bug report to Mendix because this is not correct in my opinion.