count the number of Saturdays between two dates?

  • 0
  • 1
  • Question
  • Updated 2 weeks ago
  • Answered
I need to count the number of Saturdays between two dates. Any ideas?
Photo of @lin

@lin

  • 820 Points 500 badge 2x thumb

Posted 3 weeks ago

  • 0
  • 1
Dealing with dates can be tricky. Something along these lines should work:

var number WEEKDAYADD = If(DayOfWeek([Date Two])=6,1,0);

ToDays((FirstDayOfWeek([Date Two])-FirstDayOfWeek([Date One])))/7 + $WEEKDAYADD

Basically, I'm adjusting the dates to both startĀ at the beginning of the week, so that I can calculate the number of whole weeks, between them (and thus the Saturdays). Since the calendar starts on Sunday the first week will always have a Saturday in it. To compensateĀ for the last week I check the day that the date falls on and either add one or zero to the total weeks.

I haven't tested it for all scenarios.

-Sharon
(Edited)