-
zehrabatoolAsked on June 6, 2017 at 1:20 AM
i want to calculate the time in the following field, how can i achieve this?
Page URL: https://form.jotform.me/71480846819467 -
Nik_CReplied on June 6, 2017 at 3:58 AM
Maybe you could enable time range for one time field:
And then you could add Text field that could show the range:
And it would look like this:
Could that work for you?
Please let us know.
Thank you!
-
zehrabatoolReplied on June 6, 2017 at 4:43 AMNo it won’t be working for me.
As I won’t hours and minutes separately in text field.
As I have shown you in a figure below.
I don’t want it to be done by using date picker field. How can I obtained it by using only time field?
Regards
zehra
... -
zehrabatoolReplied on June 6, 2017 at 4:43 AMNo it won’t be working for me.
As I want hours and minutes separately in text field.
As I have shown you in a figure below.
I don’t want it to be done by using date picker field. How can I obtained it by using only time field?
Regards
zehra
... -
Nik_CReplied on June 6, 2017 at 5:38 AM
I understand.
I was able to make a logic that will calculate hours and minutes between two fields and place them in separate fields.
It's a bit complicated but it is doing what you need.
1) Change the time field to 24h time format:
And do that for both time fields.
2) The issues we have in this calculation is that we need the time and hours separated, but also we need those two correct if the value is negative, for example out time is 15:10 and in time is 10:50, if we just subtract them we will get 5h and -40 minutes, so we need some additional fields:
And Minutes total is Form calculations widget.
They could be all hidden except Hours final and minutes final since there we will show the final hours and minutes difference.
3) Now we create some conditions:
-First the hours:
Since it will be the decimal number we use the round function and that will give us hours number
-Second, we create a condition for minutes:
-To extract the actual minutes, we use the Form Calculations widget we added to the form:
We subtract the minutes and hours to get the decimal part, multiply that number with 3600 to get seconds and divide with 60 to get the minutes. Finally we round that number to get the actual minutes value.
4) To cover the negative numbers I mentioned above, we add four more conditions:
-For negative:
So if the minutes is less than zero, we subtract number one from the hours and enter in hours final field (that's our total hours) and similarly for minutes we add 60 to value so we get the number of minutes.
-For positive:
We just copy the values to hours total and minutes total.
Here is my test form so you can check it out: https://form.jotformpro.com/71561743287967
Again, the temp value fields should be hidden:
Please let us know your thoughts.
Thank you!
-
zehrabatoolReplied on June 6, 2017 at 6:43 AMWhy it’s not showing in Final hours ?
... -
liyamReplied on June 6, 2017 at 8:39 AM
Hello,
I just tested the form provided by Nik_C and the field appear to be properly filled after filling up time 1 and time 2:
Can you try refreshing the form page to see if the problem appears still?
Thanks.
-
zehrabatoolReplied on June 7, 2017 at 12:43 AMPlease kindly see this screenshot, when I am selecting time 1: 1:00 and time 2: 2:00.
It’s not showing in final hours and final minutes.
Link is as following:
https://form.jotformpro.com/71561743287967
Do you please help me as soon as possible?
... -
Nik_CReplied on June 7, 2017 at 2:15 AM
My apologies, that is happening because I didn't cover that situation. But that is easily done by adding two more conditions:
But if you don't want zero to show for minutes, you can include only first condition.
And here is my updated form: https://form.jotformpro.com/71561743287967
Let us know how it worked for you.
Thank you!
-
SafetyJNJMechReplied on June 21, 2017 at 8:42 PM
Very handy Nik_C - any chance you could update your form to include calculations that allow 2 x break time deductions to be reported?
E.g. Total hours and minutes deducted by 45mins due to a 30min and a 15 min break being included.
2 x number entries (minutes)
- break 1
- break 2
*UPDATE*
Thought this might be handy for others. I realized the 'minutes total' was a form calculation widget and simply added an extra calculation to Nik_C's original calculation '-break' (where 'break' = a number entry field, minutes).
Thanks Nik_C again for a great form
-
Chriistian Jotform SupportReplied on June 21, 2017 at 10:49 PM
@SafetyJNJMech,
Thanks for your update. Yes, you are correct, the Minutes Total field is a Form calculation widget so you can add an extra calculation to it to get the break time deduction.
We appreciate your kind words. If you have questions or concerns, please open a separate thread and we will be happy to assist you.
Regards.