-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDateWeekdaysInRange.calc
More file actions
26 lines (24 loc) · 901 Bytes
/
DateWeekdaysInRange.calc
File metadata and controls
26 lines (24 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Let ( [
dayTotal =
GetAsNumber ( GetAsDate ( dateEnd ) )
- GetAsNumber ( GetAsDate ( dateStart ) ) + 1 ;
workWeeks = Int ( dayTotal / 7 ) ;
workLeftover = Mod ( dayTotal ; 7 ) - 1 ;
workLeftover = If ( workLeftover < 1 ; 0 ; workLeftover ) ;
workLeftover = workLeftover + If ( workWeeks ≥ 1 ; 1 )
] ;
workWeeks*5 + workLeftover
)
/* __________________________________________________
NAME: DateWeekdaysInRange ( dateStart ; dateEnd )
PURPOSE: Returns number of weekdays in given range
EXAMPLES/TESTS:
List (
DateWeekdaysInRange ( "7/1/2013" ; "7/8/2013" ) = 6 /* Mon - Mon */
; DateWeekDaysInRange ( "2/14/14" ; "2/18/14" ) = 4 /* Tue - Sat */
)
HISTORY:
Created: 2011-03-25 12:52 PT - Donovan Chandler
Modified: 2013-07-09 17:11 PT - Donovan Chandler: Now includes last day in range.
Modified: 2014-02-04 15:45 PT - Donovan Chandler: Fixed bug with ranges less than a week.
*/