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.
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.