Help

Re: Counting Specific Days Between Two Dates

512 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Meredith_Rimmer
5 - Automation Enthusiast
5 - Automation Enthusiast

Hey! I’m trying to count the number of Mondays and Thursdays between two dates - does anyone have a formula or tip on how to achieve this?

20 Replies 20

I got my computer back.

Here is a more concise form of my formula.

Replace DesiredWeekday with the number for the weekday desired (Sunday = 0, Monday = 1, …) You will need to replace it in four spots.

This formula also relies on the fact that true is represented internally as 1, and false is represented internally as 0. This may not be apparent to non-coders. It is also not documented, so is subject to change, although it is so standard that I do not expect it to change.

DATETIME_DIFF(End, Start, 'weeks')
+ 
IF(
  WEEKDAY(End) >= WEEKDAY(Start),
  AND(
    WEEKDAY(End) >= DesiredWeekday,
    WEEKDAY(Start) <= DesiredWeekday
  ),
  OR(
    WEEKDAY(End) >= DesiredWeekday,
    WEEKDAY(Start) <= DesiredWeekday
  )
)