Doing validations using the day of the week

Do you have a datepicker and want to create validations using the selected day of the week? Like for example your business is closed on sundays and open later on mondays and want to validate this in your form? If so keep reading.

The first thing you will need is a date picker:

Then you need to create a "Make field invalid depending on a condition"

This type of validation is a little more complex so for this example we are going to use the 'Formula' conditional logic

These types of conditions let you use formulas to create conditions (more about formulas here: https://sfmanual.rednao.com/documentation/calculatedfields/creating-formulas/)

If for example, you want to throw an error message if the date selected fall on sunday you need to create a formula like this:

GetDayOfWeek(): This will get the day of the week of the 'Date' field in the following format:
0: Sunday
1: Monday
2: Tuesday
3: Wednesday
4: Thursday
5: Friday
6: Saturday

I want to show an error message when the selected day is sunday so i am creating a condition like this: Date.GetDayOfWeek()==0

And that's it! now my form is going to show an error message if my user select a date that falls on sundays:

Now what happen if you want to do more than one validation? For example, let's say that on mondays you open at 12pm so only on mondays you don't want to accept times earlier than 12pm? 

To have a validation like this you just need to use an slightly different formula:

In this formula we are now checking that the day of the week is monday (with this code Date.GetDayOfWeek()==1), then we check that the selected time (in the time field) is less than 43200000 (43200000 is the number of milliseconds between 0:00 am and 12pm) and if so we are showing an error message like this:

That's it! Now my form has validations using the day of the week!