can someone explain this

D

dlb1228

im new to writing code
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 1

i believe the first line says show the difference between the 2 dates by
number of days then what is the - then ww is weekdays not sure
about the 7 and the last line can someone explain this to me.
 
K

Klatuu

Since I wrote it, I guess I should explain it.
The last argument of the DateDiff function is DayOfWeek.
This argument will alter the return value of the DateDiff function.
To make it simple, what is is doing is subtracting all the Saturdays and
Sundays.
 
Top