Question
· Nov 7, 2017

ZEN : Allow multiple date formats in a dateText control and converting them to the YYYY-MM-DD

There is  a finite list of date formats that users want to use to enter a date in a form. These formats include single digits for month and day and double digits for year.  The field is represented by a dateText control.

How would one get to allow a dateText control to accept multiple date formats ? I see only 3 listed here, do those include using single digits for month and day ?

I tried to set the value of format = "#(myPageProperty.myValue)# " but I got a compilation error in Studio so that went nowhere. Has anyone ever been able to set the format value depending on the user input value?

I am guessing that the control input value must be converted to the YYYY-MM-DD before validation. I am open to calling a javascript function to do that but where would be the best place to put it?

Discussion (1)1
Log in or sign up to continue

as posted on stackoverflow:

for details see Class %ZEN.Component.dateText

setting format:
Property format As %ZEN.Datatype.string(MAXLEN = 3, VALUELIST = ",MDY,DMY,YMD", ZENEXPRESSION = 1)
you have exactly 3 formats or "" 

Your guess on values is correct and documented:   
/// The value of this control is always in the canonical form: YYYY-MM-DD

As this is one of the oldest components of ZEN your only chance to achieve
your way of operation is to create your own version inheriting from
Class %ZEN.Component.dateText and overloading the parts you want to change