Forum Discussion

AlinMihalcea1's avatar
AlinMihalcea1
Qrew Assistant Captain
7 years ago

count the number of Saturdays between two dates?

I need to count the number of Saturdays between two dates. Any ideas?
  • 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