cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Validation Rule to Check Day of Date?

Jump to solution

Within Nintex Forms 2013, I am looking to verify a date that was selected is actually a Sunday, and not another day of the week. I have the following in a validation rule on the date control, but it doesn't appear to fire when the form is submitted. What am I missing?

 

contains(formatDate({Self},D),"Sunday") == "0"

 

Thanks!

Jess

Labels: (2)
Reply
9 Replies
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

Hi Jess,

as a work around for now, add a Calculated Value control (call it something like MyCV) onto your form and configure with something like this:

contains(formatDate(MyDate,'D'),'Sunday')

Where MyDate is the name of your date control.

Then in your validation rule, set it to:

not(equals(MyCV,'true'))

This should work for you.  I'll look into why all of that in a Validation Rule isn't working and will get back to you.

cheers,

Vadim

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

Hi Jess,

 

the formula itself is almost correct. It is just missing the quotation marks "D". By using "D' it will return a string like this: "

 

contains(formatDate({Self},"D"),"Sunday")

 

 

equals(formatDate({Self},"dddd"),"Sunday") -> "dddd" will format the date as just the day's name, "Sunday" for example.

 

In either case, the formula will return TRUE (i.e. show the error message you specified) if the day is Sunday and FALSE (i.e. the error message will not be shown) if the day is not a Sunday, so the comparison in your formula is not required.

 

Hope that helps,

Pat

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

That's awesome Pat. I wonder why our other formula didn't work. Thanks for sharing the solution.

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

Not sure which reply you read, but I edited the first reply. The only thing in the original formula that was missing was the quotation marks aorund the "D"

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution


aahh I didn't see that. Thanks Pat.

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

Thank you Pat and Vadim! Thanks for catching the typo in my original post, and then showing me a better validation check. I modified it slightly for my case, in which I want to say the date is invalid if it is not a Sunday:

not(equals(formatDate({Self},"dddd"),"Sunday") )

Thanks again!

Jess

0 Kudos
Reply
Not applicable

Re: Validation Rule to Check Day of Date?

Jump to solution

Patrick Hosch‌ awesome solution, Do you know how to get business hours like this?

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

that will be a rather long expression as you'd need to combine the above with OR statements for each day of the week and another regular expression to check for the time range. This will get rather ugly. You'd be better served creating your own inline function that does that as part of the code. If you need advise on how to create your own inline function, please refer to this article.

0 Kudos
Reply
Workflow Hero

Re: Validation Rule to Check Day of Date?

Jump to solution

contains(formatDate({Self},'D'),'Monday') == "0"

This works for me. Thanks.

0 Kudos
Reply