Discussions

Expand all | Collapse all

count the number of Saturdays between two dates?

  • 1.  count the number of Saturdays between two dates?

    Posted 10-26-2018 14:36
    I need to count the number of Saturdays between two dates. Any ideas?


  • 2.  RE: count the number of Saturdays between two dates?

    Posted 11-01-2018 23:10
    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