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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal - Calculate business hours

Status
Not open for further replies.

sasa353

Technical User
Apr 23, 2010
2
EU
Tried KenHammady solution for calculating business hours but no joy. I get error for NumberVar Days := {@Business Days Formula}; "This field name is not known". It's the first time I work with Crystal and obviously am doing something wrong. Please, help!
 
YOu will need to show all your formula. especially {@Business Days Formula} and how you are developing Ken H's formula.

Ian

 
Hi IanWaterman and thanks for replying. Below is what I’m using to calculate business days and hours, skipping weekends. These are KenHammady solutions I found a few days ago and am trying to put them together. Programming is not my cup of tea. I’m doing it because there’s nobody else. I appreciate your help.

//Main formula
WhileReadingRecords;
Local DateVar Start := date({my.field.1}); // place your Starting Date here
Local DateVar End := date({my.field.2}); // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;

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);


WhileReadingRecords;
NumberVar Days := {@Business Days Formula}; // The field that calculates your business days
TimeVar SetStart := TimeValue( "8:00"); // The start your work day
TimeVar SetEnd := TimeValue("17:00"); // The end your work day
TimeVar StartTime := TimeValue({my.field.1});// The data field that holds your Start Time
TimeVar EndTime := TimeValue({my.field.2}); // The data field that holds your End Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top