Can Weekends be Excluded from the Results of DateTime Calculations?

  • jenebo
    Asked on October 7, 2015 at 11:27 AM

    Part of one of our forms is a user requesting something done by slecting a radio button of 3 days. 2 weeks, 3 weeks, etc. To add to this, we have an "other" field that I think I can populate using a "date" field that would be filled out below the radio button section (maybe make the choosable date filed appear if the :other" radio button is selected).

    What my real question is, how do I have the form generate a date that that customer can expect to have their services complete by based on WORKING days (Monday through Friday), excluding weekends (and holidays if possible) and display that?

     

    Thanks

  • BJoanna
    Replied on October 7, 2015 at 2:10 PM

    If I understood you correctly you want to calculate number of days, between start date and end date, but you want to exclude weekends and holidays. Unfortunately it is not possible to exclude weekends and holidays when using a date calculation.

    However it is possible to calculate difference between two dates. Here is my sample form:

    http://form.jotformpro.com/form/52795517569977?

    I have added two DateTime fields and used form calculation widget to calculate difference between dates. https://www.jotform.com/help/259-How-to-perform-calculation-in-the-form 

    Can Weekends be Excluded from the Results of DateTime Calculations? Image 1 Screenshot 20

    Feel free to clone it

    You can also use our "Limit Dates" feature, if you do not want that your users select weekends in DateTime field. Inside of this guide you can find out how to do it:

    https://www.jotform.com/help/337-How-to-Use-the-Limit-Dates-feature-in-a-DateTime-field 

    Hope this will help. Let us know if you need further assistance.

  • dakotahorizons
    Replied on October 8, 2015 at 12:08 PM

    What we are looking to do is take today's date, add a specified amount if time to it in days, and output the calculated date.

    The output date cannot be a weekend and if possible, the calculation cannot include weekends.

     

    Is this possible?

  • Ashwin JotForm Support
    Replied on October 8, 2015 at 2:25 PM

    Hello dakotahorizons,

    What we are looking to do is take today's date, add a specified amount if time to it in days, and output the calculated date.

    I have understood your this requirement and it seems to be achievable. 

    Can you please explain your next requirement on what happens if the output date is a weekend.

    We will wait for your response.

    Thank you!

  • dakotahorizons
    Replied on October 8, 2015 at 5:12 PM

    We do not want weekends to count as part of the output calculation, nor do we want the output date to be a weekend.

  • abajan Jotform Support
    Replied on October 8, 2015 at 8:20 PM

    Unfortunately, excluding weekends from the output calculation doesn't appear to be feasible. (There's actually currently at least one ticket about this.) However, let me see if I can devise a workaround of some sort and get back to you.

    Thanks

  • abajan Jotform Support
    Replied on October 8, 2015 at 10:13 PM

    Hi again,

    Please test this form and note the date displayed in the Result field as different selections are made in the Due Date field. Is that the sort of functionality you wanted?

    We'll await your reply.


    Thanks

  • jenebo
    Replied on October 14, 2015 at 11:18 AM

    Hi abajan,

    Yes, this is EXACTLY what we were looking for. Now, how do I make this work in my form?

     

    Thanks again

  • Ashwin JotForm Support
    Replied on October 14, 2015 at 1:31 PM

    Hello jenebo,

    I am glad to know that my colleague's workaround works for you. Can you please let us know in which field of your form you want the result/date excluding dates to be displayed? We will surely try to help you. Is it "Date:" field below the "Name of Event" field?

    We will wait for your response.

    Thank you!

  • dakotahorizons
    Replied on October 14, 2015 at 5:28 PM

    I have made a read-only field called 'Expected Completion Date."

     

    Thank you for all your help!

  • abajan Jotform Support
    Replied on October 14, 2015 at 9:38 PM

    Hi again,

    Please clone this clone of your form (see this guide) back to your account and note the following:

    1. A date field has been inserted and its Default Date has been set to the Current:

    Can Weekends be Excluded from the Results of DateTime Calculations? Image 1 Screenshot 50


    2. The said field is hidden:

    Can Weekends be Excluded from the Results of DateTime Calculations? Image 2 Screenshot 61


    3. The following calculation values have been added to the Timeline field:

    Can Weekends be Excluded from the Results of DateTime Calculations? Image 3 Screenshot 72

    (Since a week is equal to seven [7] days, 7 and 14 have been used as the calculation values for 1 Week and 2 Weeks respectively.)


    4. A text box field labelled Evaluate has been added to the form and it is hidden

    5. Four (4) Update a Form Field Value conditions have been added to the form:

    Can Weekends be Excluded from the Results of DateTime Calculations? Image 4 Screenshot 83

    Carefully examine each of them and after a while the logic of their settings should become clear but if you need help understanding any of this, please inform us.

     

    Cheers