can someone explain this

G

Guest

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with my function vba code 1
CalcWorkDays error 1
Can't query DateDiff 3
Number of days 9
Infamous Business Day Count 7
working days 4
Function Strangeness 8
subtract days without weekends or holidays 1

Top