How to Calculate Date Differences Excluding Sundays ?

  • Acknowledgement
    Asked on September 2, 2024 at 3:42 AM

    Good day,

    Is there a way that I can add a condition that automatically calculate a number of days on my form from 2x date pickers, and with that exclude a specific day (in this case any SUNDAYS must not be calculated)

    For example, on my leave form template, I want the employees to select the period they will be taking leave, and then the number of days they will be taking leave calculates and populates automatically, but my condition must not calculate Sundays.

    Thanks

    How to Calculate Date Differences Excluding Sundays ? Image 1 Screenshot 20

  • Emma JotForm Support
    Replied on September 2, 2024 at 4:26 AM

    Hi Acknowledgement,

    Thanks for reaching out to Jotform Support. You can easily calculate the difference between dates without including Sundays by adding a Dates Difference Widget to your form. Let me walk you through it, step by step:

    1. In Form Builder, click on Add Form Element on the left side of the page.

    2. Under the Widgets tab at the top of the Form Elements menu, search for the Dates Difference widget.

    3. Click on the Dates Difference widget to add it to your form.

    How to Calculate Date Differences Excluding Sundays ? Image 1 Screenshot 60

    Now, let's configure your Dates Difference widget to exclude Sundays from the calculation:

    1. Select the Dates Difference widget on your form and click on the Wand icon that comes up on the right side of the widget field.

    2. In the Widget Settings menu that comes up on the right, check the checkbox on the left side of the Sunday field under the Exclude field to exclude Sundays from the calculation.

    3. Click on the Dropdown menu under the Calculate Difference field and select Yes.

    4. Then, click on Update Widget at the bottom right corner of the Widget Settings menu.

    How to Calculate Date Differences Excluding Sundays ? Image 2 Screenshot 71

    Next, we will add a Form Calculation Widget to your form to display the result:

    1. Click on Add Form Elements on the left side of the page.

    2. Under the Widgets tab at the top of the Form Elements menu, search for the Form Calculation widget.

    3. Click on the Form Calculation widget to add it to your form.

    How to Calculate Date Differences Excluding Sundays ? Image 3 Screenshot 82

    Let's configure the Form Calculation widget to show the result of the days’ calculation:

    1. Select the Form Calculation widget on your form and click on the Wand icon that comes up on the right side of the widget field.

    2. In the Form Calculation Widget menu that comes up on the right, click on Add Field.

    3. In the Dropdown menu that pops up, select the Dates Difference widget to include it in your calculation.

    4. Then, click on Save at the bottom right side of the Form Calculation Widget menu.

    How to Calculate Date Differences Excluding Sundays ? Image 4 Screenshot 93

    Check out the screencast below to see my result:

    How to Calculate Date Differences Excluding Sundays ? Image 5 Screenshot 104

    Keep us updated and let us know if you need any more help.

  • Acknowledgement
    Replied on September 2, 2024 at 4:52 AM

    Thank you - can you please advise and assist with the following:

    According to my calculations, below example needs to be a total of 7 leave days (2nd to 7th = 6 days, excluding Sunday, + 9th = total of 7 days, but below calculates 6 days).

    Thanks

    How to Calculate Date Differences Excluding Sundays ? Image 1 Screenshot 20

  • Lara JotForm Support
    Replied on September 2, 2024 at 5:15 AM

    Hello Acknowledgement,

    Keep in mind that the Dates Difference widget only calculates the number of days between selected dates. For example, if you input September 2 to September 9 and exclude Sundays, the calculation will subtract 1 day for Sunday (September 8) from the total days. Therefore, the result will be 6 days.

    Let us know if you need any more help.

  • Acknowledgement
    Replied on September 3, 2024 at 2:37 AM

    Thank you,

    is there any settings I can change that it counts the actual of days (not just the difference), including the start and end date (excluding Sundays) as per my message above?

  • William JotForm Support
    Replied on September 3, 2024 at 3:00 AM

    Hi FPG Group,

    You can set the formula in your form calculation widget adding a "+ 1" like this:

    How to Calculate Date Differences Excluding Sundays ? Image 1 Screenshot 20

    This should show the correct value you are expecting for your leave dates.

    Give this a try and let us know how it goes.

  • Acknowledgement
    Replied on September 3, 2024 at 3:05 AM

    Thanks for this - Working now as needed :)

Your Answer