BradCustom
IS-IT--Management
I'm working with Crystal 2008 on a report were I'm trying to find the number of regular hours and overtime hours within a date range.
I've created a formula that works as long as the report's date range is either less than 7 days or if greater than 7 days, then it needs to be run in multiples of 7.
Below are three of the formulas, the first is to find the number of days.
@TotReportDays
@TotRegPayrollHrs
@TotOTPayrollHrs
What I'd like is to beable to run this report for any number of days. Presently if the report's date range is greater than 7 but not a multiple of 7 then the Total Regular Hours and Total OT Hours caulation returns an incorrect value.
Thanks for your help!
I've created a formula that works as long as the report's date range is either less than 7 days or if greater than 7 days, then it needs to be run in multiples of 7.
Below are three of the formulas, the first is to find the number of days.
@TotReportDays
Code:
DateDiff ("d",{@MinWorkDate} ,{@MaxWorkDate} )
@TotRegPayrollHrs
Code:
if ({@TotReportDays}) <= 7
then
(
if (((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))>40
then 40
else (((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))
)
else
(
if ({@TotReportDays}) > 7
then
(
if (((((({@TotReportDays})/7)*40)-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee})) > Sum ({@PayrollLineHrs}, {Employee.Employee})
then
Sum ({@PayrollLineHrs}, {Employee.Employee})
else
((((({@TotReportDays})/7)*40)-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))
)
@TotOTPayrollHrs
Code:
if ({@TotReportDays}) <= 7
then
(
if (((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))>40
then (((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))-40
else 0
)
else
(
if ({@TotReportDays}) > 7
then
(
if (((((({@TotReportDays})/7)*40)-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee})) < (((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))
then
(((Sum ({@PayrollLineHrs}, {Employee.Employee})-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee})) - ((((({@TotReportDays})/7)*40)-Sum ({@EmpDayHolHrs}, {Employee.Employee}))-Sum ({@EmpDaySickHrs}, {Employee.Employee}))-Sum ({@EmpDayVacHrs}, {Employee.Employee}))
else 0
)
What I'd like is to beable to run this report for any number of days. Presently if the report's date range is greater than 7 but not a multiple of 7 then the Total Regular Hours and Total OT Hours caulation returns an incorrect value.
Thanks for your help!