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
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: "Thursday, August 28, 2014" in which case you can use the contains() function.
contains(formatDate({Self},"D"),"Sunday")
If you are just interested in the day I'd recommend using:
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
That's awesome Pat. I wonder why our other formula didn't work. Thanks for sharing the 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"
aahh I didn't see that. Thanks Pat.
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
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.
contains(formatDate({Self},'D'),'Monday') == "0"
This works for me. Thanks.