Hello,
I have the following code for a simple timesheet. I would like to add in a meal break field that can be taken off a total and am having trouble with the script.
The 4 fields in question are: rosstartmon (this is the shift start time), rosfinmon (this is the shift finish time), rosmealmon (the meal break) and the calculation field which is ResultHours. All fields are time/date fields other than the ResultHours field which is a text field.
Here is the code I use to work out hours worked
cqnursetimesheet.timesheet1.ResultHours::calculate - (FormCalc, client)var TimeCountvar OneMinute = 1/60if (rosstartmon ne null and rosfinmon ne null) then //if start time is lower than end time. if (Time2Num(rosstartmon.formattedValue, "HH:MM") < Time2Num(rosfinmon.formattedValue, "HH:MM")) then TimeCount = Abs(Time2Num(rosstartmon.formattedValue, "HH:MM") - Time2Num(rosfinmon.formattedValue, "HH:MM")) /(60 * 60 * 1000) //If start time is higher than end time else TimeCount = 24 - Abs(Time2Num(rosfinmon.formattedValue, "HH:MM") - Time2Num(rosstartmon.formattedValue, "HH:MM")) /(60 * 60 * 1000) endif var Minutes = Round(TimeCount / OneMinute) var Hours = 0 for i = 0 upto 48 step 1 do if (Minutes >= 60) then Minutes = Minutes - 60 Hours = i + 1 endif endfor $ = Concat(Hours, ":", Minutes, "")endif
How do I add the meal break time into this code so that if the user enters (for example) 30 (for 30 minutes) it will take it off the total hours worked.
Thanks in advance
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.