I have successfully implemented S.Y.M. Wong-a-Ton's calculation of the
difference between two dates that can be found here:
http://enterprise-solutions.swits.net/infopath2003/article.php?t=datediff-vbscri
pt-infopath&c=infopath2003
I was wondering if there is a way to adapt this (or do something different)
so that is shows the number of work days (instead of calendar days)? Like the
NETWORKDAYS function in Excel. I'm not much with VBScript, so samples and/or
examples would be great!
S.Y.M. Wong-A-Ton - 01 Feb 2007 07:54 GMT
You need to look into using the Weekday function (see
http://msdn2.microsoft.com/en-us/library/t51x9wtx.aspx) to detect and count
which days within the period of days were week days.
One way to do this is as follows: Once you've calculated how many days there
are between the two dates, begin at the start date and loop through all the
days one by one. Use the DateAdd function to increment the date everytime by
1 day, and check whether that day was a week day by using the Weekday
function. If it was, increment a counter that tracks how many week days there
were between the two dates.
Unfortunately, I do not have any code for this.
---
S.Y.M. Wong-A-Ton
> I have successfully implemented S.Y.M. Wong-a-Ton's calculation of the
> difference between two dates that can be found here:
[quoted text clipped - 4 lines]
> NETWORKDAYS function in Excel. I'm not much with VBScript, so samples and/or
> examples would be great!
S.Y.M. Wong-A-Ton - 05 Feb 2007 08:25 GMT
I just posted an article that should help you a bit with this issue. See
http://enterprise-solutions.swits.net/infopath2003/article.php?t=calculate-work-
days-between-two-date-pickers-infopath-vbscript&c=infopath2003
---
S.Y.M. Wong-A-Ton
> I have successfully implemented S.Y.M. Wong-a-Ton's calculation of the
> difference between two dates that can be found here:
[quoted text clipped - 4 lines]
> NETWORKDAYS function in Excel. I'm not much with VBScript, so samples and/or
> examples would be great!