Counting specific days \ day types between 2 dates.

Counting specific days \ day types between 2 dates.

A user asked it was possible to count the number of working (weekdays) between 2 dates.  They had considered the function Datediff()  within an expression but realised  this simply counts the total number of days between 2 dates.
 

Our suggestion was to make use of the SelectedDays() expression function.

 

This takes 3 parameters:

 

1 First Date

2 Second Date

3 The 7 digit string of bits representing the days Monday to Sunday, in that order. So, "1111111" would be every day and "1111100" would just be weekdays and "0000011" would be just weekends.

 

 As an example, this would return the number of weekdays between these two dates:

 

SelectedDays(20240708,20241208,"1111100")

 

This example below would give you the number of Mondays:

 

SelectedDays(20240708,20240720,"1000000")

 

The user concerned was using date variables rather than date literals but the expression would still give the required result, using the pattern of "1111100"

 .
e.g.in the Apteco training Holidays system using the first and last booking dates for a person:


So 13 weekdays between the first booking 01/02/2023 and second 19/02/23.