If you need to derive the weekday from a date field or the Date Picker, you can use the following formula:
How does this work?
When calculating with a date field we get a decimal number as a result.
(see: How to calculate with days and minutes)
The 7th of July 2020 is represented by the value 18449.9166.
Where 18449 is the number of days since 1/1/1970 and the decimal 0.9166 a fraction of a day to represent the time.
Adding 4 days
In our formula we first add 4 days to the Date Picker value:
Because the 1/1/1970 - day zero - was a Tuesday. And in the calculation, we want to end up with Monday as 1, Tuesday as 2, etc.
By adding 4 we are adjusting the number for the weekday we will get at the end of the calculation.
For more background please see e.g. https://stackoverflow.com/questions/36389130/how-to-calculate-the-day-of-the-week-based-on-unix-time
Simulating a Modulo Operation
The next trick is to simulate a Modulo function (which we don’t have available in Adalo).
This can be done using the following formula:
Don’t get confused: It is basically to find out the remaining number of days after the division with 7 (days per week).
Basically, we take the number of days and divide it by 7.
In the result we get 2636 full weeks = 18452 days and a remainder of 0.2738… weeks = 1.91 days:
The remainder of the days is the part we are interested in.
We round the 1.91 up to 2 days, which corresponds to the second day after a full week = Tuesday.
We now have the weekday available to filter for example on time slots open for booking on a selected date.:
Available slots for day 2, Tuesday:
Available slots for day 4, Thursday: