Forum Discussion

TylerFoy81's avatar
TylerFoy81
Qrew Member
2 days ago

Count days between 2 dates with a twist

I have a Start date and end date I am using the Weekdaysub(end date), (Start Date). but i want to add a IF statement like say to add saturdays to the mix.

so if I was to set the date from 5/25/2025 and end on 5/30/2025 but if the saturdays check box was clicked it would also add the saturdays between those dates and return 6 (Monday-Saturday) and if the saturdays was not checked it would return 5 (Monday - Friday)

2 Replies

  • Mez's avatar
    Mez
    Qrew Assistant Captain

    WeekdaySub() excludes the end date in the calculation by design. If you're expecting 5 days using these dates, it will return 4. 

    If you're good with this from this function, then you can simply check for the checkbox and add 1 to the calc otherwise just return the calc. If not, and you truly want 5 days, then return 6 from these dates, you'll need to add 2 using this function or perform a different calculation.

    // assumes your "Saturday" field is entitled "Saturday?" - add 1 day where Sat is checked

    If(

      [Saturday?], WeekdaySub([End Date], [Start Date]) + 1,

      WeekdaySub([End Date], [Start Date])

    )

    • TylerFoy81's avatar
      TylerFoy81
      Qrew Member

      ahh I didnt notice this my Start Date always starts with a Sunday and the end date is always a saturday... so I was getting the 5 days everytime then I made another field that simply divides the days by 5 so if one set of dates had 25 days then there was 5 saturdays between those dates. then just use the check box to count the other 5 days if checked. but after reading this i can see this may have some issues.