Print Page | Close Window

Business Day count

Printed From: Crystal Reports Book
Category: General Information
Forum Name: Talk with the Author
Forum Discription: Ask Brian questions about his books and give him your comments. Like the book? Hate the book? Have suggestions? Let me know!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4097
Printed Date: 11 May 2024 at 2:25pm


Topic: Business Day count
Posted By: cmariemd
Subject: Business Day count
Date Posted: 27 Aug 2008 at 9:11am
Can anyone tell me how to correct the program below so the consecutive days continue to add up even if the month changes?
 
Shared NumberVar consecDays;
Shared NumberVar consecDaysMax;
if(Previous({TR_CC_HRIS_MAND_ABS_BY_SUPVID.TR_GEMS_ID}) = {TR_CC_HRIS_MAND_ABS_BY_SUPVID.TR_GEMS_ID} and
   DateDiff("d",Previous({TR_CC_HRIS_MAND_ABS_BY_SUPVID.RETURN_DT}), {TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT}) <= 1 or
   (DateDiff("d",Previous({TR_CC_HRIS_MAND_ABS_BY_SUPVID.RETURN_DT}), {TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT}) = 2 and
    DayofWeek(DateAdd("d",-1,{TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT})) in [1,7] and
    DayofWeek(DateAdd("d",-2,{TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT})) in [1,7])) then
    consecDays:= consecDays + DateDiff("d",{TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT},{TR_CC_HRIS_MAND_ABS_BY_SUPVID.RETURN_DT})
else
    consecDays:= DateDiff("d",{TR_CC_HRIS_MAND_ABS_BY_SUPVID.BEGIN_DT},{TR_CC_HRIS_MAND_ABS_BY_SUPVID.RETURN_DT});
if(Previous({TR_CC_HRIS_MAND_ABS_BY_SUPVID.TR_GEMS_ID}) <> {TR_CC_HRIS_MAND_ABS_BY_SUPVID.TR_GEMS_ID}) then
    consecDaysMax := consecDays
else if(consecDaysMax < consecDays) then
    consecDaysMax := consecDays;

consecDays
 
 example:  hrs = 8.00     days = 7     hrs= 56.00


-------------
Cynthia W



Print Page | Close Window