Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Date format consistency

Avatar

Level 3

I'll have a wide ranging audience who will be completing various forms I deliver.

I have date fields that offer the date chooser of course and the pattern is set to DD/MM/YYYY.

However, some of my users tend to enter dates any way they like - eg. 280511 or 28.05.11 or 28/5/11, etc.

These 3 are the most common varieties.  When they enter any of these, the field accepts their entry as is.

Apart from a Tooltip, prompt or help text or whatever to tell them how to enter the field, what script could I use to convert the above 3 types of entry into the correct date format?

Thanks,

Peta

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Peta,

You can achieve this by leaving the display pattern of the date/time field as: date{DD/MM/YYYY}.

Then in the edit pattern you would specify all of the possible combinations that users input dates:

date{DD/MM/YYYY}|date{DD.MM.YY}|date{DD.M.YY}|date{D.M.YY}|date{D.MM.YY}|date{DDMMYY}

Each pattern is separated by a |.

Hope that helps,

Niall

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi Peta,

You can achieve this by leaving the display pattern of the date/time field as: date{DD/MM/YYYY}.

Then in the edit pattern you would specify all of the possible combinations that users input dates:

date{DD/MM/YYYY}|date{DD.MM.YY}|date{DD.M.YY}|date{D.M.YY}|date{D.MM.YY}|date{DDMMYY}

Each pattern is separated by a |.

Hope that helps,

Niall

Avatar

Level 3

Hi Niall,

Well now there's a funny thing.  In Design view it displays an 'invalid pattern' message.  Yet I could see the separators were correct.  So I gave it a go anyway and despite the error message in Design view - it works a treat.

Thanks again Niall

Avatar

Level 10

Hi Peta,

You should not get an error in the design view. I think it would be a good thing to recheck the edit pattern. Make sure that there isn't a surplus |, either at the begining or end of the string. Also double check that each individual pattern is correct and complete, eg date{DD.MM.YY}

At least you are closer to a solution,

Niall