<?xml version="1.0" encoding="utf-16"?>
<Function xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.caseware-idea.com/">
    <Author>brian.element</Author>
    <DateModified>2014-02-20</DateModified>
    <FunctionName>weekday_dif</FunctionName>
    <Help>This will calculate the number of business days between two dates.  The function assumes that Saturday and Sunday are not business days.</Help>
    <OutputType>Numeric</OutputType>
    <FunctionBody>'****************************************************************************************************
'* Custom Function:		weekday_dif
'* Author:	Brian Element - brian.element@ideascripting.com
'* Date:		Feb 20, 2014
'* Purpose:	to calulate the number of business days between two dates
'* This script is provided without any warranty or guarantee.  Anybody using this script
'* is encouraged to validate the effectiveness and reliability on their own.
'* For instructions on how to use this script please see http://www.ideascripting.com/ideascript/import-multiple-files
'****************************************************************************************************

Option Explicit
Function weekday_dif(StartDate As Date,EndDate As Date) As Double
	Dim numWeekdays As Integer
	Dim totalDays As Integer
	Dim weekendDays As Integer
	Dim i As Integer
	numWeekdays = 0
	WeekendDays = 0
	
	totalDays = DateDiff("d", StartDate, EndDate) + 1
	
	For i  = 1 To totalDays
		If Weekday(startDate) = 1 Then
			WeekendDays = WeekendDays + 1
		End If
		If Weekday(startDate) = 7 Then
			WeekendDays = WeekendDays + 1
		End If
		startDate = DateSerial(Year(startDate), Month(startDate), Day(startDate) + 1) 
	Next

	weekday_dif = totalDays 	- WeekendDays
End Function
</FunctionBody>
    <Parameters>
        <Parameter>
            <Type>Date</Type>
            <Name>StartDate</Name>
            <Help>Starting Date</Help>
        </Parameter>
        <Parameter>
            <Type>Date</Type>
            <Name>EndDate</Name>
            <Help>Ending Date</Help>
        </Parameter>
    </Parameters>
</Function>