Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace holiday formula from Ken

Status
Not open for further replies.
Sep 12, 2005
448
US
Hi All.
cr 9.0
ms sql
I used Ken formula for the Holiday
here is what it looks like
BeforeReadingRecords;
DateVar Array Holidays := [
Date (2007,1,1),
Date (2007,1,15),
Date (2007,2,19),
Date (2007,4,6), //changing
Date (2007,5,28), //changing
Date (2007,7,4),
Date (2007,9,3), //changing
Date (2007,11,22), //changing
Date (2007,12,25)
];
0
they must change the date for each year.
I found this table holiday that has these value

table Holiday

field:
Holiday_id*******Holiday_Dt*******Description
1**********01/01/2007 12:00:00 AM**New Year's Day
2**********01/15/2007 12:00:00 AM**Martin Luther King
3**********02/19/2007 12:00:00 AM**President's Day
4**********04/06/2007 12:00:00 AM**Good Friday
5**********05/28/2007 12:00:00 AM**Memorial Day
6**********09/03/2007 12:00:00 AM**Labor Day
7**********11/22/2007 12:00:00 AM**Thanksgiving Day
8**********12/25/2007 12:00:00 AM**Christmas Day
9**********07/04/2007 12:00:00 AM**Independence Day


how can i replace Ken's formula holiday with this table.
To used the Holiday_Dt instead
If possible they will not have to manually change the date of the holidays
--------------------------------------
the first part of the other formula to calculated the working days is this

WhileReadingRecords;
Local DateVar Start := Date(year({?End_Date}),1,1); // place your Starting Date here
Local DateVar End := {?End_Date}; // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;

Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);

Local NumberVar i;
For i := 1 to Count (Holidays)
do (if DayOfWeek ( Holidays ) in 2 to 6 and
Holidays in start to end then Hol:=Hol+1 );

Weeks + Days - Hol



Thanks

pg

Durango122
if it moves and should not used Duck Tape
if does not move and should used WD-40
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top