I have a written a validation Rule which makes the field required, Now Management want not to make this field required but when somebuddy enter the value, it should make sure that it is filled in the correct format.

Current formula:-

        REGEX(AppealDate__c, "[0-9]{2}/[0-9]{2}")
    VALUE(RIGHT(AppealDate__c, 2)) > 31,
    VALUE(LEFT(AppealDate__c, 2)) > 12

It's a Date field and the format should be like MM/DD. Can you help how to accomplish this goal.

  • 1
    If the field is of type Date, you don't need to verify its format. The format displayed depends on the user locale. Feb 9, 2017 at 14:34

1 Answer 1


I think you are using text datatype for field AppealDate__c ,then

AND(NOT(ISBLANK(AppealDate__c)) ,(OR(NOT(REGEX(AppealDate__c, "[0-9]{2}/[0-9]{2}")),VALUE(RIGHT(AppealDate__c,2))>31,VALUE(LEFT( AppealDate__c ,2))>12)))

above formula will work.

  • This answer could be improved if you went into detail about why you think this validation rule would work (as well as detail about what is different between your answer and the original validation rule provided in the question). Code dumps without explanation don't do much to help anyone grow as a programmer.
    – Derek F
    Feb 9, 2017 at 15:04
  • Also, the question does mention that AppealDate__c is, in fact, a Date field.
    – Derek F
    Feb 9, 2017 at 15:06
  • I made my assumption on formula given by @rakesh . Because he was using his field directly in regex which only accepts String as first attribute. Feb 9, 2017 at 15:10
  • @DerekF how the field in format MM/DD can be a Date type?
    – o-lexi
    Feb 9, 2017 at 18:06
  • @Oleksiy it can't (as you probably know, due to how Salesforce displays date/datetime fields). The original poster (OP) of the question is either mixing terminology, or doesn't know about how Date fields work in Salesforce (which Martin's comment on the question clarifies).
    – Derek F
    Feb 9, 2017 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .