Payroll Calculation

wendy1967

New member
Local time
Today, 03:02
Joined
Dec 2, 2005
Messages
8
I am trying to type a code based on 1 & 2 criterias. However, I am having a problem on the first criteria because it is adding 8 hours when it shouldn't. Can someone help to either fix my code or write a new one? Thank you very much!

Criteria 1: If the day_of_wk is 1, calculate time-reg_time/60, If the day_of_wk is 1 and time is less than 0, calculate time-reg_time/60+24

Criteria 2: If the day_of_wk is 2, calculate time/60, If the day_of_wk is 2 and time is less than 0, calculate time/60+24

My code: pre: IIf([day_of_wk]="2",[time]/60,IIf([time]<0,([time]-[reg_time])/60+24,([time]-[reg_time])/60))
 
REPayroll Calculation

Don't think you need the "" round the 2
 
I can't make much sense of what you are doing. How can you have a negative time?

Can you give some sample data and results to show what is happening.
 
The end-user has to input these fields:
Start Date
Time In
Time Out

For Example:
Start Date: 12/01/2005
Time In: 10:00 pm
Time Out: 6:00 pm

The expected result should be 8 hours but right now it is giving -16. This is why I needed to add 24 to the first condition.

The "" in 2 is needed as 2 is a text and not a number.
 
Clearly, the data is producing a false result on both comparisons and the caculation ([time]-[reg_time])/60 is being executed.

You aren't giving us much information to work on, though. What data types are you using for the user input? I presume it's not date/time. The [time] and [reg_time] fields must be in minutes. How does [time] become negative? How do you derive the day_of_week value?
 

Users who are viewing this thread

Back
Top Bottom