Former Member
Dec 10, 2009 at 10:52 PM

# Need to make these functions work to add the repository

12 Views

Hello:

I need to add the following two functions to the repository, but they both have errors that I don't know how to correct.

#1

// BusinessDays function for calculating the number of business days between a date range

Function (datevar Start, datevar End)

Local NumberVar Weeks;

Local NumberVar Days;

Local Numbervar Hol;

Weeks:= (Truncate (End u2013 dayofWeek(End) + 1 u2013 (Start u2013 dayofWeek(Start) + 1)) /7 ) * 5;

Days := DayOfWeek(End) u2013 DayOfWeek(Start) + 1 +

(if DayOfWeek(Start) = 1 then -1 else 0) +

(if DayOfWeek(End) = 7 then -1 else 0);

// Count the number of holidays in the date range

Local NumberVar i;

For i := 1 to Count (Holidays)

do (if DayOfWeek ( Holidays<i> ) in 2 to 6

and Holidays<i> in Start to End then Hol:=Hol+1 );

// Calculate the number of business days

Weeks + Days u2013 Hol

#2

Function () DateVar Array

// List of the holidays to exclude from business days calc

Holiday := [

Date (2009,01,01), // New Years Day

Date (2009,01,19), // Martin Luther King, Jr.

Date (2009,02,16), // Presidents Day

Date (2009,05,25), // Memorial Day

Date (2009,07,04), // Independence Day

Date (2009,09,07), // Labor Day

Date (2009,10,12), // Columbus Day

Date (2009,11,11), // Veterans' Day

Date (2009,11,26), // Thanksgiving Day

Date (2009,12,25) // Christmas Day

];

Thank you very much!

Deanna