Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Exclude holiday days from formula Post Reply Post New Topic
Author Message
whitey1987
Newbie
Newbie


Joined: 10 Jun 2011
Online Status: Offline
Posts: 1
Quote whitey1987 Replybullet Topic: Exclude holiday days from formula
     Posted: 10 Jun 2011 at 11:11pm
Hi All,

Hope one of you nice people can help me out with this. I have a formula that calculates the time it takes for employees to input a job card. However, it currently only excludes weekends and I would like it to exclude holiday days.

Can anyone add to the code below, or advise me on how this can be done? I'm using Crystal Reports 10.

IF {VM_001_HDR.JC_RECEIVED_2} = {VM_001_HDR.JC_INPUT_2} THEN

(CDBL(MID({VM_001_HDR.JC_INPUT},1,2))+ ((CDBL(MID({VM_001_HDR.JC_INPUT},4,5))/100)/0.6))

-

(CDBL(MID({VM_001_HDR.JC_RECEIVED},1,2))+ ((CDBL(MID({VM_001_HDR.JC_RECEIVED},4,5))/100)/0.6))

ELSE

(

Local Numbervar x;
Local NumberVar Hrs := 0;
Local DateVar EvaluateDate := Date(Dateadd("d",1,{VM_001_HDR.JC_RECEIVED_2}));
Local NumberVar Days := DATEDIFF("D",{VM_001_HDR.JC_RECEIVED_2},{VM_001_HDR.JC_INPUT_2}) - 2 ;


For x := 0 to Days do
(
If DayofWeek (EvaluateDate) in [2,3,4,5,6]
Then Hrs := Hrs + 24
Else Hrs := Hrs;

EvaluateDate := Date(DateAdd("d",1,EvaluateDate));
);
Hrs


+

(CDBL(MID({VM_001_HDR.JC_INPUT},1,2))+ ((CDBL(MID({VM_001_HDR.JC_INPUT},4,5))/100)/0.6))

+

(24 - (CDBL(MID({VM_001_HDR.JC_RECEIVED},1,2))+ ((CDBL(MID({VM_001_HDR.JC_RECEIVED},4,5))/100)/0.6)))
)
IP IP Logged
freestylepunk
Newbie
Newbie
Avatar

Joined: 05 May 2011
Location: United States
Online Status: Offline
Posts: 13
Quote freestylepunk Replybullet Posted: 14 Jun 2011 at 2:30pm
Are you storing these holiday dates on a table in the database?
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 21 Jun 2011 at 9:41am
YOU COULD CREATE A LIST OF HOLIDAY DATES (AS A FORMULA) LIKE
IF DATE(FIELD) = ["HOLIDAY DATE1","HOLIDAY DATE2"....] THEN  DATE(FIELD)

AND THEN EXCLUDE RESULT OF THAT FORMULA FROM YOU ORIGINAL FORMULA.


Edited by kostya1122 - 21 Jun 2011 at 9:41am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum