-
mattshafferAsked on May 13, 2025 at 12:16 PM
I am using the "Dates Difference" widget on a form that is intended for employees to submit for vacation time. The calculation is only tallying "night". For example, if they select Wednesday to Friday as there vacation days...the difference is returning "Difference 2". That is correct if it was a hotel stay (2 nights). But the teachers will be out a total of three days: Wednesday, Thursday, and Friday.
Is there a way to correct this or work around this? I need my output to be Dates and Difference for the way it integrates with my sheets.Thanks!
Matt
-
Silvano JotForm SupportReplied on May 13, 2025 at 1:20 PM
Hi Matt,
Thanks for reaching out to Jotform Support. Regarding your issue with the "Dates Difference" widget counting nights instead of total days for vacation time, this is because the widget calculates the difference between dates as the number of nights between them, similar to a hotel stay.
To count the total days including both the start and end dates (for example, Wednesday to Friday as 3 days), you can use an advanced formula in Jotform Tables instead of relying solely on the widget. Here's how to do it:
- Use the DATETIME_DIFF function to calculate the difference between the start and end dates in days.
- Add 1 to the result to include both the start and end dates in the total count.
For example, the formula would look like this:
=DATETIME_DIFF({Start Date}, {End Date}, "days") + 1
This formula will return the total number of days including both the first and last day, which fits your need for vacation days counting.
If you want to keep the widget but need the correct total days for integration with your sheets, consider adding a calculation field with this formula to adjust the output accordingly.
Give it a try and let us know how it goes.
-
Matt ShafferReplied on May 14, 2025 at 12:55 PM
Ok thanks! I'll try it.
-
mattshafferReplied on May 14, 2025 at 1:53 PM
Ok this is what I am trying to do: use the Date Diff formula you suggested and add it to a column. However, I don't see how to reference the column that has the original output from my form...like this...
How do I create a formal column that extracts JUST THE DATE DIFF +1?
-
Silvano JotForm SupportReplied on May 14, 2025 at 2:58 PM
Hi Matt,
You'll need to do it on the submission table. Let me show you how:
- In Jotform Tables, click on + Add column header.
- Now, click on Formula tab and click on Advanced Formula and click on Next button.
- Enter the column name and click on Next button.
- Finally, setup the formula based on your requirement.
That's it. Give it a try and let us know if you need any other help.
-
mattshafferReplied on May 14, 2025 at 4:06 PM
Silvano - thank you for the response. I understand how to create a formula using the Advanced Formula. My issue is that I do not see the columns I need to select under the Columns box on bottom left of your GIF. It appears you didn't select any specific column and yet you got a return. but the GIF cuts off before I can see what the return was. I am working with this return box:
Start Date: 05/14/2025 End Date: 05/16/2025 Exclude: Sunday,Saturday Difference: 2 days
The name of the column is: Please select a SINGLE DATE or CONSECUTIVE DATE RANGE:I am using a Date Diff widget.
-
Silvano JotForm SupportReplied on May 14, 2025 at 4:32 PM
Hi Matt,
I tested to recreate the Advanced Formula on my end but it seems it doesn't allow selecting the Start and End date on the Date Difference Widget. I suggest using two Date Fields one for the Start and one for the End of leave request. This should work properly.
Give it a try and let us know how it goes.