Unable to dynamically use date in labels due to datetime error

I have a form where there is a dropdown and date range that appears accordingly. So, if dropdown is 1, then 2 date fields appear: Date A and Date B (format yyyy/MM/dd) If dropdown is 2, then 2 date fields appear, Date C and Date D. Now below this is a label, The range is from Date {1} to Date {2} In the text edit options, for parameters i have used expression for {1} as: If $currentobject/dropdown/name = '1’ then formatDateTime($object/DateFieldA,'yyyy/MM/dd’) else if $currentobject/dropdown/name = '2’ then formatDateTime($object/DateFieldC,'yyyy/MM/dd’) For {2}: If $currentobject/dropdown/name = '1’ then formatDateTime($object/DateFieldB,'yyyy/MM/dd’) else if $currentobject/dropdown/name = '2’ then formatDateTime($object/DateFieldD,'yyyy/MM/dd’) Now, on application, when i select say 1 from dropdown, the date fields are selected and label shows correct date fields. i.e. Range is from 2021/01/01 to 2021/02/02 However when i change value in dropdown it throws error: An error occurred while evaluating value of Object_NewEdit.text3: (text box) Operator formatDateTime not supported in expression formatDateTime(, yyyy/MM/dd)      at f (http://localhost:8080/mxclientsystem/mxui/mxui.js?637695809765167197:73:97482) What could be the reason?
1 answers

Sounds like a bug.

First try this: replace the formatDateTime(..)  by just $object/DateFieldX, it probably works perfectly. So you know it is the formatDateTime in the text-widget’s parameter-expression.

Second: try and upgrade to 9.6.0, see if the bug is still there. If so report it to support@mendix.com

Third: an alternative is to duplicate the text-widget and show/hide each by visibility->expression->$currentobject/dropdown/name = '1’  or ‘2’.