function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JaxBeachJaxBeach 

How Do I ensure a certain date formatting in a field?

I have a text field that is actually for a date, but they only want Year/Month - how can I ensure that the date gets entered as yyyy/mm (all numeric)?

 

Thanks so much :)

Best Answer chosen by Admin (Salesforce Developers) 
@anilbathula@@anilbathula@
Hi JaxBeach,

Try this validation rule:-
NOT(REGEX(Text_field__c,"[0-9]{4}[/]{1}[0-9]{1,2}"))



All Answers

@anilbathula@@anilbathula@
Hi JaxBeach,

Try this validation rule:-
NOT(REGEX(Text_field__c,"[0-9]{4}[/]{1}[0-9]{1,2}"))



This was selected as the best answer
JaxBeachJaxBeach

Thank you so much - worked perfectly.  :)