How to derive weekdays from a date

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)

For example:
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.

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:


Awesome! Thanks for sharing!

1 Like

@karimoo I have tried the custom formula. I didnt get the correct value. I think the formula may be wrong.
Screenshot 2021-07-04 at 2.03.55 AM

Do you have a clone to share?

Hi @ron,

I’m using this in some of my apps (sorry can’t allow cloning them as they are for my customers), formula seems to work.

One note - for the time zones to the west of GMT, it gives 0 for Sundays; for east of GMT, it gives 7 for Sundays.

Best regards, Victor.

1 Like