Conditions for time field based on date field

  • countryk9
    Asked on December 5, 2020 at 11:09 AM

    New Customer Boarding Reservation - Testing Time Restrictions

    Boarding Reservations Page

    1st Check-In time field is for Monday-Friday 8-5pm April 1 - November 30

    2nd Check-In time field is for Saturday all year

    3rd Check-In time field is for Sunday all year

    4th Check-In time field is for Christmas eve hours 8-noon

    5th Check-In time field is for Monday-Friday 8-11am & 3-5pm December 1 - March 31

    Need to setup conditions to display Check-In Time and Check-Out Time based on the dates picked for the Check-In Date and Check-Out Date.

    For Christmas Eve (12/24), need to display a different Check-In time/Check-Out Time field. What I have tried displays the field but still displays the original at the same time.

    Need to display different Check-In Time/Check-Out Time fields for April 1 - November 30 and December 1 - March 31. What I have tried displays the field but still displays the original at the same time.

  • Welvin Support Team Lead
    Replied on December 5, 2020 at 5:14 PM

    You can set logic to target the day and specific dates (before and after). I would suggest adding a hidden calculation widget before/after the Check-In Date, and configure it to get the Date String, like the following:

    1607206127 5fcc04efcfadd  Screenshot 10

    Click the ... icon to view the DateString function:

    math functions conditions v4 Screenshot 21

    Next, set up your conditional logic like this:

    1607206213 5fcc0545b4e6a  Screenshot 32

    The overall conditional logic is the following:

    1607206463 5fcc063fda905  Screenshot 43Here's a demo form you can check with this method: https://form.jotform.com/203396226856059.

    I hope that helps.

  • countryk9
    Replied on December 14, 2020 at 12:51 PM

    Can you provide more detail with the step "Click the ... icon to view the DateString function:". I'm unclear at what to do.

  • Jessica JotForm Support
    Replied on December 14, 2020 at 4:37 PM

    Hi countryk9, thank you for reaching us.

    Please allow me to try to explain to you steps by steps.

    The solution that my colleague has suggested could be broken down into 2 steps.

    1. Using Form Calculator to identify what day is the dates
    2. Using Conditional Logic to show the time according to the day


    Using Form Calculator to identify what day is the dates

    Through our built-in feature, our Form Calculator offers a way to convert date into text.

    To do this, we simply need to add the following formula: dateString(select date field).

    1607981779 5fd7dad3c7189 OnPaste Screenshot 10

    This will automatically allow output such as "Tue, Dec 16 2020", which is important to identify the days as there are different times for specific days.


    Using Conditional Logic to show the time according to the day

    Afterward, we can add as many dropdown option fields at different times. Taking my colleague's demo as an example, Time (5) contains a time range from 8AM to 5PM with 30 minutes differences.

    1607981793 5fd7dae164a71 OnPaste Screenshot 21

    Then, we can simply add a condition to show Time (5). We can set Condition from Settings > Conditions within JotForm's Form Builder.

    Still following the demo my colleague has prepared as an example below:

    1607981805 5fd7daedf18d4 OnPaste Screenshot 32

    The condition state, if the date is after November 30th, but before April 1th and the date string contains Mon, Tue, Wed, Thu, Fri, then it will show Time (5).

    This method can be repeated for other time fields based on a certain date.


    Let us know if it is still confusing for you.


  • countryk9
    Replied on December 15, 2020 at 4:49 PM

    Clone of Existing Customer Boarding Reservation

    If Arrival Date: After "2020-11-30"

    If Arrival Date: Before "2021-04-01"

    and

    If Arrival Date: After "2021-04-01"

    If Arrival Date: Before "2021-11-30"

    I've tried using ANY and ALL if the rules are matched. Using ANY displays both Arrival Time dropdowns, ALL displays none.

  • Ariel JotForm Support
    Replied on December 15, 2020 at 8:44 PM

    Hello there,

    Please note that the day of the week should be in ddd – three-letter abbreviation format, e.g. Tue.

    16080829622020 12 16 09 41 47 Screenshot 10

    Also, the "ANY" rule will not work in your case since you have a strict set of conditions.

    Let us know if you have any questions or if you need further assistance.

  • countryk9
    Replied on December 16, 2020 at 11:22 AM

    Changed the the day of the week to ddd (Mon, Tue, Wed, Thu, Fri). Changed to ALL. Still no date field is being displayed.

  • Kenneth JotForm Support
    Replied on December 16, 2020 at 12:42 PM

    Hi there,

    Using the same rules on the conditions, you may change the parameters for the "Value" to either "Sat" or "Sun" and select the field you wish to be shown:

    1608140334 5fda462ea01e5 y1 Screenshot 10

    I hope that helps.

    Best.

  • countryk9
    Replied on December 16, 2020 at 3:22 PM

    Sat and Sun have nothing to do with the displaying the times for Mon, Tue, Wed, Thu, Fri.

    If Arrival Date: After "2020-11-30"

    If Arrival Date: Before "2021-04-01"

    If Date String Contains "Mon, Tue, Wed, Thu, Fri"

    If "All" of the "If" rules are matched,

    Show Arrival Time:

    No Arrival time field is displayed when I put in a date for Mon - Fri.1608150417 5fda6d9167926 Screenshot   No Screenshot 10

  • Jessica JotForm Support
    Replied on December 16, 2020 at 4:52 PM

    Hi countryk9, thank you for providing us with more information.

    It looks like the following Conditional Logic is what caused the conflict:

    1608155137 5fda80016b8c5  Screenshot 10

    Please kindly disable or remove it so that the Monday to Sunday's Arrival Time could be displayed.

  • countryk9
    Replied on December 21, 2020 at 10:32 AM

    I removed the Conditional Logic for Christmas eve. It displays the correct Arrival Time field for Dec 1 - March 31 but does not display the correct Arrival Time field for April 1, 2021 - Nov. 30 2021. I also need the one for Christmas Eve to work or really any holiday that we close half a day.1608564843 5fe0c06b939d4 Screenshot   Ar Screenshot 101608564843 5fe0c06ba8141 Screenshot   Ar Screenshot 21

  • Richie JotForm Support
    Replied on December 21, 2020 at 11:13 AM

    Please make sure you have selected the correct Arrival time.

    I would suggest you change your arrival time label to specific the correct field.

    Example. I have added AP in my arrival time field label to differentiate the dordpwon field.

    1608567017 5fe0c8e938de1 3 Screenshot 10

    Also, I would suggest hiding your arrival time fields as you're using the show condition.

    1608567102 5fe0c93e2a78f 4 Screenshot 21

    Further investigating your form, it seems your Date String form calculation widget is not working correctly as there is a space in your calculation.

    1608566958 5fe0c8aedfd26 3 Screenshot 32

    Kindly add the dateString calculation again and make sure there is no spaces.

    Let us know how it goes.