Avatar of mjbdbase
 asked on

Time2Num and Timesheets

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 TimeCount
var OneMinute = 1/60

if (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	
 		TimeCount = 24 - Abs(Time2Num(rosfinmon.formattedValue, "HH:MM") - Time2Num(rosstartmon.formattedValue, "HH:MM")) /(60 * 60 * 1000) 

	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
	$ = Concat(Hours, ":", Minutes, "")

Open in new window

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
JavaScriptAdobe Acrobat

Avatar of undefined
Last Comment
James Murrell

8/22/2022 - Mon
Richard Quadling

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
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.
ask a question
James Murrell

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Your help has saved me hundreds of hours of internet surfing.