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!

Division By Zero Error

Status
Not open for further replies.

stumpyx

Programmer
Jul 5, 2002
15
CA
I've been having a problem with a division by zero error in one of my formulas. I see absolutely no reason for this to be happening.

the forumula is as follows:

numberVar workDays;
numberVar eightHourShare := 0;
numberVar sevenHalfHourShare := 0;
numberVar sevenQuarterHourShare := 0;

if Sum ({TIME_ENTRY.HOURS}, {EMPLOYEE_STATUS_MAP.ID}) <> 0 then
( numberVar eightHourShare := (Sum ({@8 Hour Project}, {EMPLOYEE_STATUS_MAP.ID}) / Sum ({@Hours In Status}, {EMPLOYEE_STATUS_MAP.ID}) * 8);
numberVar sevenHalfHourShare := (Sum ({@7.5 Hour Project}, {EMPLOYEE_STATUS_MAP.ID}) / Sum ({@Hours In Status}, {EMPLOYEE_STATUS_MAP.ID}) * 7.5);
numberVar sevenQuarterHourShare := (Sum ({@7.25 Hour Project}, {EMPLOYEE_STATUS_MAP.ID}) / Sum ({@Hours In Status}, {EMPLOYEE_STATUS_MAP.ID}) * 7.25);
);

dateVar startDate;
dateVar endDate;
(if {EMPLOYEE_STATUS_MAP.START_DATE} in [{?Date-Range}] then
startDate := date({EMPLOYEE_STATUS_MAP.START_DATE})
else
startDate := Minimum({?Date-Range}));

(if not (isnull({EMPLOYEE_STATUS_MAP.END_DATE})) then
if {EMPLOYEE_STATUS_MAP.END_DATE} in [{?Date-Range}] then
endDate := date({EMPLOYEE_STATUS_MAP.END_DATE})
else
endDate := Maximum({?Date-Range})
else
endDate := Maximum({?Date-Range}));

WhilePrintingRecords;
dateVar Start := startDate;
dateVar End := endDate;
NumberVar Weeks;
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);

workDays := Weeks + Days;

workDays * (eightHourShare + sevenHalfHourShare + sevenQuarterHourShare)

If anybody could offer some assistance it would be much appreciated.
 
Sorry I didn't quite look it over enough before asking for answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top