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!

counting holidays from table problem 1

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
US
Hi. I have a report that uses Ken Hamaday's working days formula. I am now trying to add in the holidays from a table instead of hardcoding.
I don't get any errors but it always returns 0 for number of holidays. Can someone see what I've done wrong?
Code:
 Holidays Sub
@HolDate
whileprintingrecords;
shared datetimevar array Holidays;
numbervar i := i+1;
numbervar j := count({WSSC_HOLIDAY.HOLIDAY_DATE});

if i <= j then (
redim preserve Holidays[j + 1];
Holidays[i] :={WSSC_HOLIDAY.HOLIDAY_DATE}
);
Code:
@workdays10 (10 hour day)(main report)
I placed the holiday subreport in report header area.
WhilePrintingRecords;
Local DateVar Start;
Local DateVar End;
Local NumberVar Weeks; 
Local NumberVar Days; 
Local Numbervar Hol;
Local Numbervar TotDays;
Local Numbervar MonthNum;
Local NumberVar Weds;

Shared DateTimeVar 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[i]) in 2 to 6 and Holidays[i] in start to end then Hol:= Hol + 1);

  
Weds:= DateDiff ("ww", Start, End, crWednesday);
   If DayOfWeek(Start) = crWednesday Then 
    Weds := Weds + 1  
   else
    Weds ; 

//Weeks
//Days
Hol
//Weds
  
//(Weeks + Days - Hol - Weds)
 
Where is the subreport placed in the main report? In what report section is the Business Days formula placed? The sub must be in a section above the one in which it is referenced. You could put it in the report header, e.g.

-LB
 
Lb - Sorry for delay in answering but was on different project for a few days.
The holiday's sub is in the Report Header
I should have also told you that the start and end days are passed from another formula because the report can be run for multiple months or just one month
The days formula is in GF4.
RH - Holidays Sub
GH1 - Mydate - yearly
GH2 - Mydate - Monthly
GH3 - WrkType (work/personal[sick, training, annual])
GH4 - Employee
DETAILS - counts of all work performed
GF 4 - Sum of detail columns. this is the section that contains the work days formula.

If I display holidays, then I get a 0 when I should get at least a 1 for the month I'm running it for (7/1/2011 - 7/31/2011)
Thanks lhuffst
 
You have to establish values for thes two variables, e.g.

Local DateVar Start := {table.startdate};
Local DateVar End := {table.enddate};


-LB
 
LB - If I am running this (potentially) for multiple months and time that could include multiple years. do I need a formula that pushes the end dates per month or will CR automatically count the days properly per month? I had a formula that is like
Code:
If Month({Command.MYDATE}) =  01  Then
  If Month({Command.MYDATE}) = Month({?BeginDate}) and 
          Month({Command.MYDATE}) = Month({?EndDate}) then
          (
           Start := {?BeginDate};
           End := {?EndDate}
          )
    else
	(
	   Start := Date(Year({?BeginDate}),01,01);
	   End := Date(Year({?EndDate}),01,31)
Now I'm questioning if I even need to do this type of formula.
thanks lhuffst
 
LB - just changed it...works like a charm. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top