I am using crystal reports 2008. I am calcuating the number of business days between two dates using the formula below:
WhileReadingRecords;
Local DateVar Start:= date({s_srv_req.CREATED});
Local DateVar End:= date({s_srv_req.ACT_CLOSE_DT});
Local Numbervar Days;
Local Numbervar Weeks;
Local Numbervar Hol;
Datevar Array Holidays;
Weeks:=(Truncate(End-dayofWeek(End) + 1
-(Start - dayofWeek(Start) + 1))/7)*5;
Days:=DayOfWeek(End)-DayOfWeek(Start) +
(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
Everything works fine. Except now I need to figure out how to use the DateTimeVar instead of the DateVar. I want to show anything less than 24 hours would be considered 0 days. So if the create date was 10/4 at 5:00pm and the closed date was 10/5 at 9:00am it should show 0 days because it was less than 24 hours. Right now it shows as a 1 day difference, because I was not thinking in terms of hours versus days.
I am thinking I need to use something like:
Local DateTimeVar Start:= date({s_srv_req.CREATED}, time(#08:00am);
Local DateTimeVar End:= date({s_srv_req.ACT_CLOSE_DT}, time (#17:00pm);
Any ideas?
Thanks to all!!!
WhileReadingRecords;
Local DateVar Start:= date({s_srv_req.CREATED});
Local DateVar End:= date({s_srv_req.ACT_CLOSE_DT});
Local Numbervar Days;
Local Numbervar Weeks;
Local Numbervar Hol;
Datevar Array Holidays;
Weeks:=(Truncate(End-dayofWeek(End) + 1
-(Start - dayofWeek(Start) + 1))/7)*5;
Days:=DayOfWeek(End)-DayOfWeek(Start) +
(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
Everything works fine. Except now I need to figure out how to use the DateTimeVar instead of the DateVar. I want to show anything less than 24 hours would be considered 0 days. So if the create date was 10/4 at 5:00pm and the closed date was 10/5 at 9:00am it should show 0 days because it was less than 24 hours. Right now it shows as a 1 day difference, because I was not thinking in terms of hours versus days.
I am thinking I need to use something like:
Local DateTimeVar Start:= date({s_srv_req.CREATED}, time(#08:00am);
Local DateTimeVar End:= date({s_srv_req.ACT_CLOSE_DT}, time (#17:00pm);
Any ideas?
Thanks to all!!!