-
Mustapha_cmsDear Support Team,
Good day.
I am currently experiencing difficulty calculating the duration (in days, hours, and minutes) between two date-time fields in Jotform.
I have attempted several formulas using the Form Calculation widget; however, the results are inconsistent, particularly for the minutes calculation.
Could you kindly advise on the correct formula or recommended approach to accurately calculate the difference between two date-time fields (including days, hours, and minutes)?
Your assistance on this matter would be greatly appreciated.
Thank you.
Page URL: https://form.jotform.com/212620840087451 -
Podo: Support SpecialistHi Mustapha_cms,
Thanks for reaching out to Jotform Support. I'm an AI assistant here to assist you.
To accurately calculate the duration between two date-time fields (including days, hours, and minutes) in Jotform, the recommended approach is to use the Date Difference widget. This widget automatically calculates the difference between two dates and times.
Here’s how to add and configure the Date Difference widget:
- Open your form in Form Builder and click Add Element.
- Go to the Widgets tab and search for Dates Difference.
- Click the widget to add it to your form.
- Click the widget's Wand icon to open settings.
- In the General tab, scroll down and select your preferred Submission Result Format (e.g., difference in days, hours, and minutes).
- Click Update to save the settings.
This widget will then calculate the difference between your two date-time fields accurately.
If you prefer to use the Form Calculation widget for this, you need to convert the date-time values into milliseconds and then calculate the difference. Jotform’s Form Calculation widget supports functions like days(), hours(), and minutes() to convert time units into milliseconds.
Here is a general approach for the calculation formula:
- Calculate the difference between the two date-time fields in milliseconds.
- Use floor() and modulo operations to extract days, hours, and minutes from the total milliseconds.
For detailed setup and examples, you can refer to Jotform’s guide on using the Form Calculation widget and the Date Difference widget.
Let me know if you want a step-by-step formula example for the Form Calculation widget or further assistance with the Date Difference widget.
Give it a try and let us know how it goes.
-
Mustapha_cmscan you give example for the calculation form ?
-
Podo: Support SpecialistHi Mustapha_cms,
Let me help you with an example formula for calculating the duration between two date-time fields in the Form Calculation widget, including days, hours, and minutes.
Assuming you have two date-time fields named {StartDateTime} and {EndDateTime}, here is a general approach:
- Calculate the total difference in milliseconds: {EndDateTime} - {StartDateTime}
- Extract days: Use floor((difference) / days(1)) to get the number of full days.
- Extract hours: Use floor(((difference) % days(1)) / hours(1)) to get the remaining hours after days are removed.
- Extract minutes: Use floor(((difference) % hours(1)) / minutes(1)) to get the remaining minutes after hours are removed.
In the Form Calculation widget, the formula might look like this (replace field names with your actual field IDs):
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"This formula calculates the difference, breaks it down into days, hours, and minutes, and concatenates the result as a readable string.
Make sure to enable the Result Field is Read Only option in the widget settings to prevent manual edits.
If you want, I can guide you step-by-step on how to set this up in your form.
Give it a try and let us know how it goes.
-
Mustapha_cmsplease guide me
-
Podo: Support SpecialistHi Mustapha_cms,
Let me walk you through setting up the duration calculation between two date-time fields using the Form Calculation widget in Jotform:
- Add your date-time fields: Make sure you have two DateTime fields in your form, for example, StartDateTime and EndDateTime.
- Add the Form Calculation widget: Go to the Widgets tab, search for Form Calculation, and add it to your form.
- Open the widget settings: Click on the wand icon of the Form Calculation widget to open its settings.
- Enter the formula: Use the following formula, replacing the field names with your actual field names:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes" - Save and test: Click Save to apply the formula. Preview your form and enter date-time values to see the calculated duration displayed.
Note: Enable the Result Field is Read Only option in the widget settings to prevent users from editing the calculated result manually.
If you encounter any issues or need further assistance, feel free to ask.
Give it a try and let us know how it goes.
-
Mustapha_cmsi dont understand how to input this formula into form calculation widget?
-
Podo: Support SpecialistHi Mustapha_cms,
Let me help you understand how to input the formula into the Form Calculation widget in Jotform. Here’s how to do it step-by-step:
- Add the Form Calculation widget to your form: In Form Builder, click on Add Element on the left side, go to the Widgets tab, search for Form Calculation, and add it to your form.
- Open the widget settings: Click on the wand icon on the Form Calculation widget to open the formula editor.
- Add fields to the formula: Click the Add Field button above the formula keypad to select your date-time fields (e.g., {StartDateTime} and {EndDateTime}). They will appear in the formula editor with a blue background.
- Enter the formula: Use the formula keypad and keyboard to type the formula. You can use functions like floor(), days(), hours(), and minutes() by clicking the purple f(x) button to add them. Make sure to replace the field names with your actual field IDs. For example:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes" - Set field formats: Ensure that the fields and functions appear with a dark gray background in the formula editor, indicating they are treated as numbers and functions, not text.
- Save the formula: Click Save to apply the formula to the widget.
- Configure widget options: In the widget settings, enable Result Field is Read Only to prevent manual edits.
This setup will calculate the duration between your two date-time fields and display the result as days, hours, and minutes.
If you want, I can provide screenshots or a more detailed guide on each step.
Give it a try and let us know how it goes.
-
Mustapha_cmscan i type word days , hours and minute in the form calculation widget? because it seems number to me
-
Podo: Support SpecialistHi Mustapha_cms,
In the Form Calculation widget, you cannot directly type words like "days", "hours", and "minutes" as plain text because the widget primarily handles numerical calculations.
However, you can include these words as part of the formula by concatenating them as strings using quotation marks. For example, in the formula editor, you would write:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"Here, the words " days ", " hours ", and " minutes" are treated as text strings and will appear in the result alongside the calculated numbers.
Make sure to use quotation marks around these words to include them properly in the output.
Give it a try and let us know if you need any further help.
-
Mustapha_cmsi get aswer like this - days(1)"days"2.73%days(1)hours(1)"hours"2.73%hours(1)minutes(1)"minutes". can you assist me more futher, still do not understand how to input the formula
-
Podo: Support SpecialistHi Mustapha_cms,
It seems you are having trouble inputting the formula correctly in the Form Calculation widget. Let me help you with that.
In the Form Calculation widget, you need to use the formula editor properly by adding fields and functions step-by-step rather than typing the entire formula as plain text.
Here’s how to input the formula correctly:
- Add the Form Calculation widget to your form.
- Open the widget settings by clicking the wand icon.
- Add your date-time fields by clicking the Add Field button and selecting your StartDateTime and EndDateTime fields. They will appear as variables in the formula editor.
- Use the function buttons (like floor(), days(), hours(), and minutes()) by clicking the purple f(x) button to insert them properly.
- Concatenate text strings like " days ", " hours ", and " minutes" by typing them with quotation marks around them in the formula editor.
- Ensure the formula looks like this in the editor:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes" - Save the formula and preview your form to test the calculation.
If you want, I can provide a detailed visual guide or screenshots to help you through this process.
Give it a try and let us know how it goes.
-
Mustapha_cmsshould i type " days" , "hours" and " minutes", seems not in the fx?
-
Podo: Support SpecialistHi Mustapha_cms,
Yes, you should type " days", " hours", and " minutes" exactly like that in the formula editor, including the quotation marks. These are text strings that will be concatenated to the numerical results to make the output readable.
In the Form Calculation widget, the f(x) button is used to insert functions like floor(), days(), hours(), and minutes(). However, for text strings such as " days", " hours", and " minutes", you simply type them directly into the formula editor surrounded by quotation marks.
So your formula should look like this in the editor:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"Give it a try and let us know if you need any further assistance.
-
Mustapha_cmshow about % should i type to and hour() use fx right?
-
Podo: Support SpecialistHi Mustapha_cms,
Yes, for the % (modulo) operator and functions like hours(), you should use the f(x) button in the Form Calculation widget to insert them properly.
Here’s how to handle them:
- Use the % operator directly in the formula editor to calculate the remainder (modulo) between values.
- Insert functions like floor(), days(), hours(), and minutes() by clicking the purple f(x) button. This ensures they are recognized as functions.
So, your formula will combine these operators and functions correctly, for example:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"Give it a try and let us know if you need any more help.
-
Mustapha_cms"days"2.73%"hours"2.73%"minutes" - i got answer like this
-
Podo: Support SpecialistHi Mustapha_cms,
The result you are seeing like "days(1)\"days\"2.73%days(1)hours(1)\"hours\"2.73%hours(1)minutes(1)\"minutes"" indicates that the formula is not being input correctly in the Form Calculation widget.
Make sure you are not typing the entire formula as plain text. Instead, use the formula editor and follow these steps:
- Add your date-time fields by clicking the Add Field button so they appear as variables.
- Use the function buttons (purple f(x) button) to insert functions like floor(), days(), hours(), and minutes().
- Type the text strings like " days ", " hours ", and " minutes" directly in the editor with quotation marks.
- Use the % operator directly in the formula editor for modulo calculations.
The formula should look exactly like this in the editor:
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"If you continue to have trouble, please let me know, and I can provide a detailed visual guide or screenshots to help you through the process.
Give it a try and let us know how it goes.
-
Mustapha_cmsyes please visual guide or screenshot
-
Podo: Support SpecialistHi Mustapha_cms,
Currently, you can't display the Number of Days calculated by the Date Difference Widget directly. But, there’s a workaround to show it in your form. Let me show you how to do it:
1. In Form Builder, click on Add Element on the left side of the page.
2. Then, in the menu that opens, click on Widgets in the top-right corner.
3. Next, click on the Form Calculation Widget to add it to your form.
4. In the menu that opens on the right, click on the Add Field button.
5. Then, select the Date Difference Widget in the Dropdown menu.
That’s it. As soon as your Date Difference widget is filled out, the date difference between the entered date will be displayed in the Form Calculation widget. Check out this screencast below:
Reach out again if you need any other help.
-
Mustapha_cmsthis form the date
without time?
-
Podo: Support SpecialistHi Mustapha_cms,
The Date Difference widget in Jotform calculates the difference between two date-time fields, including both the date and time components. It does not calculate the difference based on date only; the time is also taken into account in the calculation.
This means you can use the Date Difference widget to get the duration between two date-time fields accurately, including days, hours, and minutes.
Let us know if you have any other questions.
-
Mustapha_cmshow to get for example start on 20.03.2026 at 2100hrs and end on 23.03.2026 at 0236hrs , how to get the answer 2days 5hours and 36 minutes using date diiference and form calculation
-
Podo: Support SpecialistHi Mustapha_cms,
To get the duration between a start date-time of 20.03.2026 at 21:00 and an end date-time of 23.03.2026 at 02:36, resulting in 2 days, 5 hours, and 36 minutes, you can use the Date Difference widget combined with the Form Calculation widget in Jotform.
Here’s how to do it:
- Add the Date Difference widget to your form and configure it to calculate the difference between your two date-time fields.
- Set the Submission Result Format in the widget settings to include days, hours, and minutes.
- Add a Form Calculation widget to your form.
- Use the formula in the Form Calculation widget to break down the difference into days, hours, and minutes:
The formula looks like this (replace field names with your actual field IDs):
floor(({EndDateTime} - {StartDateTime}) / days(1)) + " days " + floor((({EndDateTime} - {StartDateTime}) % days(1)) / hours(1)) + " hours " + floor((({EndDateTime} - {StartDateTime}) % hours(1)) / minutes(1)) + " minutes"This will calculate the exact duration including the partial day and time difference, giving you the result of 2 days, 5 hours, and 36 minutes for your example.
Let us know if you need further assistance.
-
Mustapha_cmsi dont see any time field in the date diffrence widget?
-
Podo: Support SpecialistHi Mustapha_cms,
The Date Difference widget in Jotform allows you to calculate the difference between two dates and times automatically. When you add and configure this widget, you can select the preferred Submission Result Format which includes options for days, hours, and minutes.
To see and use the time component, make sure you have configured the widget settings properly:
- Click the Date Difference widget in your form.
- Click the Wand icon to open the widget settings.
- In the General tab, scroll down to the Submission Result Format section.
- Select the format that includes days, hours, and minutes.
- Click Update to save the settings.
If you do not see the time field or the option to include time, please double-check the widget configuration as it supports date and time difference calculation.
Let us know if you need further assistance.
-
Mustapha_cmsthe submission result format have this 3 option only 1. difference only , 2 . dates only, 3. dates and difference. do not have format for days , hours and minutes?
-
Podo: Support SpecialistHi Mustapha_cms,
Thank you for the clarification regarding the Submission Result Format options in the Date Difference widget.
Based on the options you mentioned:
- Difference only
- Dates only
- Dates and difference
It appears that the widget does not provide a direct format option to display the difference explicitly broken down into days, hours, and minutes within the widget itself.
In this case, the recommended approach is to use the Form Calculation widget to calculate and display the duration in days, hours, and minutes by using the formula that calculates the difference between two date-time fields as I previously shared.
You can use the Date Difference widget to get the raw difference value, then use the Form Calculation widget with the formula to break down that difference into days, hours, and minutes for display.
If you want, I can guide you on how to set this up step-by-step.
Let us know how you would like to proceed.
-
Mustapha_cmsyes please guide
-
Podo: Support SpecialistHi Mustapha_cms,
Let me guide you step-by-step on how to set up the duration calculation using the Date Difference widget and the Form Calculation widget in Jotform:
- Add the Date Difference widget to your form: In Form Builder, click Add Element, go to the Widgets tab, search for Dates Difference, and add it to your form.
- Configure the Date Difference widget: Click the widget, then click the Wand icon to open settings. In the General tab, set the Submission Result Format to Difference only (default), then click Update.
- Add the Form Calculation widget: Again, click Add Element, go to the Widgets tab, search for Form Calculation, and add it to your form.
- Open the Form Calculation widget settings: Click the wand icon to open the formula editor.
- Use the Date Difference widget field: Click Add Field and select the Date Difference widget from the dropdown. This will add the raw difference value to the formula editor.
- Enter the formula to calculate days, hours, and minutes: Use the formula below, replacing the Date Difference widget field name with the one added:
floor(({DateDifferenceWidget} / days(1))) + " days " + floor((({DateDifferenceWidget} % days(1)) / hours(1))) + " hours " + floor((({DateDifferenceWidget} % hours(1)) / minutes(1))) + " minutes" - Save the formula: Click Save to apply the formula.
This setup will calculate and display the duration between your two date-time fields as days, hours, and minutes.
Give it a try and let us know how it goes.
-
Mustapha_cmshow to convert hours to days?
-
Podo: Support SpecialistHi Mustapha_cms,
To convert hours to days in Jotform calculations, you can use the fact that 1 day equals 24 hours. So, to convert hours to days, divide the number of hours by 24.
For example, if you have a value representing hours, the formula to convert it to days would be:
{HoursField} / 24Here, {HoursField} is your field containing the hours value.
This will give you the equivalent duration in days.
Let us know if you need help applying this in your form.
-
Mustapha_cmslet say i got 2.23 days , how to convert it '
in days, hours and minutes ya
-
Podo: Support SpecialistHi Mustapha_cms,
To convert a decimal number of days like 2.23 into days, hours, and minutes in Jotform's Form Calculation widget, you can use the following approach:
- Extract the whole days: Use floor() to get the integer part of the days (e.g., 2 days).
- Calculate the remaining hours: Subtract the whole days from the total days, multiply the remainder by 24, and use floor() to get the hours.
- Calculate the remaining minutes: Subtract the whole hours from the hours calculated above, multiply the remainder by 60 to get minutes.
The formula in the Form Calculation widget would look like this (replace {DaysField} with your actual field containing the decimal days):
floor({DaysField}) + " days " + floor(({DaysField} - floor({DaysField})) * 24) + " hours " + floor(((({DaysField} - floor({DaysField})) * 24) - floor(({DaysField} - floor({DaysField})) * 24)) * 60) + " minutes"This formula breaks down the decimal days into readable days, hours, and minutes.
Give it a try and let us know if you need any further assistance.
-
Mustapha_cmsif i using date picker and time then using form calculation to substract between 2 date & time, the result should be in hours or days?
-
Podo: Support SpecialistHi Mustapha_cms,
When you use the Date Picker with time and subtract two date-time fields using the Form Calculation widget in Jotform, the result you get is in milliseconds by default. You can convert this result into hours, days, or any other time unit using the appropriate formulas.
If you want the result in hours, you can divide the difference by the number of milliseconds in an hour (using the hours(1) function). If you want the result in days, divide by the number of milliseconds in a day (using the days(1) function).
For example, to get the difference in days:
({EndDateTime} - {StartDateTime}) / days(1)To get the difference in hours:
({EndDateTime} - {StartDateTime}) / hours(1)You can also break down the difference into days, hours, and minutes using the formula I shared earlier.
Let us know if you need help setting this up.
-
Mustapha_cmsnoted result in milliseconds, how to convert it to hours?
-
Podo: Support SpecialistHi Mustapha_cms,
To convert the result from milliseconds to hours in Jotform's Form Calculation widget, you can divide the difference by the number of milliseconds in one hour.
Use this formula:
({EndDateTime} - {StartDateTime}) / hours(1)Here, hours(1) represents the number of milliseconds in one hour, so dividing by it converts the milliseconds difference to hours.
Give it a try and let us know if you need any further assistance.
-
Mustapha_cmsi didnt get the answer
-
Podo: Support SpecialistHi Mustapha_cms,
When subtracting two date-time fields in the Form Calculation widget, the result is in milliseconds by default. To convert this to hours, you need to divide the difference by the number of milliseconds in one hour using the hours(1) function.
Here’s how you can set it up:
- Add the Date Difference widget to your form to get the raw difference value.
- Add a Form Calculation widget to your form.
- Open the Form Calculation widget settings and click Add Field to select the Date Difference widget field.
- Use this formula to convert the difference from milliseconds to hours:
{DateDifferenceWidget} / hours(1)
This will give you the duration in hours.
Additionally, if you want to display the duration broken down into days, hours, and minutes, you can use the formula I shared earlier.
Here is a visual guide to help you set this up:
Give it a try and let us know how it goes.
-
Mustapha_cmsnoted but the date diffence widget do not have time input but only date. how possible to use date difference widget
-
Podo: Support SpecialistHi Mustapha_cms,
The Date Difference widget in Jotform calculates the difference between two date-time fields, including both date and time components. However, if you are only seeing date inputs without time, it might be because the date fields you are using do not include time selection enabled.
To use the Date Difference widget with time included, make sure your date fields have time selection enabled:
- Edit your date fields in the form.
- Enable the time option in the field settings so users can select both date and time.
- Use these date-time fields as inputs for the Date Difference widget.
This way, the Date Difference widget will calculate the difference including the time component.
If you still face issues, you can use the Form Calculation widget with the formula method I shared earlier to calculate the difference between two date-time fields manually.
Let us know if you need further assistance.
-
Mustapha_cmsas i mention before the date diffeerence widge only have format diffrence only, dates only and dates and differenece only.
-
Podo: Support SpecialistHi Mustapha_cms,
Thank you for your clarification regarding the Date Difference widget's Submission Result Format options: Difference only, Dates only, and Dates and difference only.
Since the widget does not provide a direct format to display the difference explicitly broken down into days, hours, and minutes, the best approach is to use the Form Calculation widget to calculate and display the duration.
You can use the Date Difference widget to get the raw difference value (in milliseconds), then use the Form Calculation widget with a formula to break down that difference into days, hours, and minutes for display.
If you want, I can guide you step-by-step on how to set this up.
Let us know how you would like to proceed.
-
Nikola JotForm SupportHi Shamsul,
I created a demo form for the date, hours, and minutes calculation that you can find here. You are welcome to test it and clone it. I used a five Form Calcultion widget to calculate this. I'll breakdown calculations you will need:
1. Raw Difference

2. Raw Hours and Minutes

3. Days

4. Hour

5. Minutes

The Raw Difference, Raw Hours, and Minutes can be hidden. Let me show you how to hide a field:
- In Form Builder, right-click on a field with your mouse and select Hide.
Let us know if you have any other questions.
Your Reply
Something Went Wrong
An error occurred while generating the AI response. Please try again!




