I'm using Oracle 10 g with Crystal XI.
I am trying to create a room utilization report by room and day of week. I've tried using the formula found in thread767-1387024 by LB to count the number of Mondays, but I'm not returning the desired results. I return 8 mondays in January.
whileprintingrecords;
datevar array Holidays;
datevar range x := date(DateTime({@Start Date})) to date(DateTime({@End Date}));
numbervar i;
numbervar j := day(maximum(x));
numbervar sun;
numbervar mon;
numbervar tue;
numbervar wed;
numbervar thu;
numbervar fri;
numbervar sat;
for i := 0 to j-1 do(
if not(minimum(x)+ i in Holidays) then
select dayofweek(minimum(x)+ i)
case 1 : sun := sun + 1
case 2 : mon := mon + 1
case 3 : tue := tue + 1
case 4 : wed := wed + 1
case 5 : thu := thu + 1
case 6 : fri := fri + 1
case 7 : sat := sat + 1
default : 0
);
I've used the formula below from Ken H. to find the number of business days excluding holidays and that works perfect to find the number of business days:
//Main formula
WhileReadingRecords;
Local DateVar Start := {@Start Date}; // 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
I tried using this formula to find the number of Fridays, but I'm not sure If I can use this formula and exclude the holiday in January. Is there a way to modify this formula to exclude the holiday or what did I do wrong with the formula lb posted in thread767-1387024
DateDiff ( 'ww' , {@Start Date} - 1 , {@End Date} , 6 )
Thank you for your time.