Create a conditional rule base on the days in the date picker.

  • Profile Image
    manager5land
    Asked on June 16, 2020 at 06:36 PM

    JF,

    I am trying to create a conditional logic for this scenario-


    Date 1- Form user inputs Date (date is visible)

    Date 2- (date is hidden) calculate the following for date 2-

    If the user inputs a date any day from 1st thru 15th, calculate date 2 to skip the next following month and insert 1st day of the month in the month after.

    If the user inputs a date from 16th thru the end of the month, then calculate date 2 to skip the upcoming month and insert 1st of the following month in date 2.


    is there a way to accomplish this?

    https://form.jotform.com/201396333840150

  • Profile Image
    Jed_C
    Answered on June 16, 2020 at 10:47 PM

    It seems possible according to our guide here https://www.jotform.com/help/443-Mastering-Date-and-Time-Calculation.

    On this sample form https://www.jotform.com/71752744778975, the calculation was able to extract the days in the calendar. That's a good indication that it may be possible to create a condition using days.

    Let me create a sample form and I'll get back to you once I have figured out the formula you need for your requirement.

  • Profile Image
    manager5land
    Answered on June 16, 2020 at 11:28 PM
    Great, thank you,
    Chris

    ...
  • Profile Image
    Jed_C
    Answered on June 17, 2020 at 10:07 AM

    I was able to find a solution. Please refer to the steps below.

    1). Create a date picker field for each month and name it according to the month it represents. Also, set the custom date on every 1st of the month.

    ex.

    1592401584custom_date.gif

    2). Add two date picker fields.

    3). Add one Form Calculation widget https://www.jotform.com/widgets/calculation

    4). In your form calculation widget, add a dateString math function and put your Date Picker #1 inside the dateString function.

    ex.

    1592401792The Easiest Online Form Builde

    Your form calculation widget will output dates like:

    Mon Jun 01 2020

    Tue Jun 02 2020

    Wed Jun 03 2020

    etc..

    We are now able to create a condition based on the ouput of your Form Calculation widget. 

    The condition goes like this.

    For June

    1592402070The Easiest Online Form Builde

    For July

    1592401946The Easiest Online Form Builde

    Please note that the +31 on the calculation field will be different per month because there are months that there's 31st and there are months that until 30th only so please check the calendar and add according to the number of days on each month.

    Here's a partial working form https://form.jotform.com/201683818743058. Please test and see if that's the requirement you are looking for.

    1592402807date_conditions.gif

    You may also clone it by following this guide https://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL so you can see how I applied the conditions.

    NOTE: I have set Date 2 as visible so you can see the value

  • Profile Image
    manager5land
    Answered on June 17, 2020 at 12:06 PM

    Jed C,

    Your logic works perfectly! However there is one issue that I would need overcome.

    My form is being created for long term usage.

    IE: Years- 2020, 2021, 2022, 2023, 2024, 2025 up to 2035.

    with your logic, I would have hundreds of date pickers.

    There must be another way?

  • Profile Image
    Kevin_G
    Answered on June 17, 2020 at 01:17 PM

    I think there could be a different way to do it and generalize the process, please allow me some time to figure a different workaround. 

    I will get back to you as soon as possible. 

    Thanks. 

  • Profile Image
    manager5land
    Answered on June 17, 2020 at 01:28 PM
    Great, thank you.
    Chris

    ...
  • Profile Image
    manager5land
    Answered on June 18, 2020 at 01:28 PM
    I wanted to follow up and see how progress was coming?
    ⁣Thank you,
    Chris
    ...
  • Profile Image
    manager5land
    Answered on June 19, 2020 at 01:02 AM

    Kevin_G,

    Not wanting to rush you, just making sure you hadn't forgotten about the date picker.

    I would rather have a slow yes, than a fast no... :)

    Thanks, Chris

  • Profile Image
    Kevin_G
    Answered on June 19, 2020 at 01:56 AM

    Apologies for the delay. 

    I have been performing some tests and found a workaround that will make the process dynamic, here is the demo: https://form.jotform.com/201698846075063

    You can clone it following this guide: https://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL 

    Here are some points that will help you understanding how this works:

    1. I have user a basic date picker element. 

    2. I use a Form Calculation element (Date string) where I insert the date picker element. 

    3. The form has 3 SubString widgets which will capture the day, month and year of the selected date, but on these widgets you need to use the field ID of the Form Calculation widget where you've copied the date picker. 

    Here is how to get the widget settings: 

    15925459392020-06-18_23h51_53.png

    4. You then need to set up the conditions as they are set up on my testing form. Here's the logic implemented: 

    - If the day is between 1 and 15, this inserts the date as the first of two months ahead. 

    - If the day is between 16 and 31, this inserts the date as the first of one month ahead. 

    I would recommend you to clone the form and check the logic implemented, so you can try to adapt the same on your form too. 

    I hope this helps. 

  • Profile Image
    manager5land
    Answered on June 19, 2020 at 04:10 AM

    Kevin_G

    Thank you for this. I will jump into this project tomorrow. I will let you know how it goes.

    Thanks,Chris

  • Profile Image
    manager5land
    Answered on June 19, 2020 at 09:31 PM

    Kevin_G,

    Works almost perfectly as designed. For some reason certain dates entered won't format correctly. For example, check the date 09/25/2022 on the form you built and you'll see what I'm talking about.

    Thank you in advance.

    Chris

  • Profile Image
    manager5land
    Answered on June 19, 2020 at 10:19 PM

    Kevin_G

    Also, the other item that I have noticed.

    I had my date picker "hidden" on the form with "today" defaulted.

    The programming that you have given me won't update without picking a date manually from the date picker.

    is there a way to have the new programming that you provided to me, to update the new field you provided me, without having the user to select a date?

    by default, the date picker will already show the date if date is set for today-

    Options- "NONE" "CURRENT" "CUSTOM".

    I would like to hide my date picker with the "TODAY" default selected.


    I use this date picker to create a pdf to send my customers. I perfer the pdf to be dated the same date as the customer fills out the form. I understand that as long as no one cheats, the date, they should be selecting the date they fill out the form. but, this isn't a fool proof way of creating my pdf.

  • Profile Image
    manager5land
    Answered on June 20, 2020 at 12:15 AM

    Kevin_G,

    Instead of checking the form that you built to find the error, please just use my form. As mine and yours are acting the same, I have reversed the 1-15th and the 16th-32nd.

    I understood your logic, but you just had the logic reversed. (I'm sure that's because of the way I tried to explain what I was trying to occomplish) I fixed it by reversing the conditional logic, but mine and your form is still not formatting correctly with the output.

    https://form.jotform.com/201708667762160

    Thanks, Chris

  • Profile Image
    Vanessa_T
    Answered on June 20, 2020 at 12:16 AM

    I would like to hide my date picker with the "TODAY" default selected.

    I assume this date picker is not related to your initial post since in the initial post you mentioned:

    Date 1- Form user inputs Date (date is visible)

    Date 2- (date is hidden) calculate the following for date 2-

    Nothing on those mentions a hidden date field with today's date. If you are indeed referring to another date picker, then please set that date picker to CURRENT so it will default to today.

    159262640100659.jpg

    For some reason certain dates entered won't format correctly. For example, check the date 09/25/2022 on the form you built and you'll see what I'm talking about.


    Please allow me some time to check on this and will get back to you afterwards.

    Also kindly confirm, if Date 1 is within 01-15, then Date 2 will be first of next month?

    Sample:

    Date 1 = Sept 5, 2020

    Date 2 = Oct 1, 2020

    Then if Date 1 is within 16-end, then Date 2 will be first of the next of the following month?

    Sample:

    Date 1 = Sept 17, 2020

    Date 2 = Nov 1, 2020

  • Profile Image
    manager5land
    Answered on June 20, 2020 at 12:50 AM

    Vanessa,

    I am so sorry, I mis-spoke on my orginal post question. This is how I should have worded it-

    Date 1- Form user inputs Date (date is hidden)

    Date 2- (date is hidden) calculate the following for date 2.

    Very sorry about that :(


    If I could explain it in this manner-

    Today's date (Hidden date picker set to "Current")=July 1, 2020

    Today's date (Hidden date picker set to "Current")=July 15, 2020

    Date 2 (First Payment Due Date)=August 1, 2020

    or

    Today's date (Hidden date picker set to "Current") = July 16, 2020

    Today's date (Hidden date picker set to "Current") = July 31, 2020

    Date 2=(First Payment Due Date) September 1, 2020


    I understand that If I set the Date picker to "Current" that the date of today will be displayed, however, Date 2 will not calculate itself.

    https://form.jotform.com/201396333840150

    Check my form with these steps-

    Step 1- Select Farm Location as "Siloam"

    Step 2- Select Farm 1

    Step 3- Click to verify Farm Availability

    Notice that I have the (hidden) date picker set to current

    Now look at (hidden) field labeled- "First Payment Due Date"

    The "First Payment Due Date" will not perform its calculation unless you could "view" the date picker and choose a date. choosing a date triggers the field "First Payment Due Date" to preform its calculation.

    I'm not sure how to automatically perform the "First Payment Due Date" calculation without the input from the form user.. (I would have to allow the date picker to be visable to the user)


    The second issue, is some formatting with some of the "First Payment Due Dates". See photo attached. This is a photo from my PDF editor. This is where the "First Payment Due Date" is inserted.

    159262831320200619_205110.jpg

  • Profile Image
    Vanessa_T
    Answered on June 20, 2020 at 01:16 AM

    Thank you for those additional information. Unfortunately, the conditions are only triggered whenever the action is performed.

    However, if your only concern is if your users do not select today's date, that can be fixed by disabling selection of past and future dates. This way, users can only select the current date and the condition will then be triggered.

    159263017300660.jpg

    Meanwhile, please see the demo form I have created with all your points noted.

    Demo form: https://form.jotform.com/201710750789963

    For demo purposes, the date is shown and you can select any date.

  • Profile Image
    manager5land
    Answered on June 20, 2020 at 01:46 AM

    Vanessa,

    Thank you very much. I've run through your date picker and it appears to work perfectly. I will review the changes you made and implement them.

    Thanks again for all your help.

    Chris

  • Profile Image
    manager5land
    Answered on June 20, 2020 at 02:15 PM

    Vanessa,

    https://form.jotform.com/201396333840150

    I can't seem to get the conditional logic #1 to accept the formula that you have given me?

    All other formulas are entered with no issues, except this one.

    I see that it worked well for you.

    Here is the conditional logic #1 that you built-

    1592676615Presentation1.jpg

    Here is conditional logic #1 that I am trying to enter-

    1592676672Presentation12.jpg

    The conditional logic will allow me to enter a +1, but its not allowing me to save a +2.

    1592676810Presentation13.jpg

  • Profile Image
    Kevin_G
    Answered on June 20, 2020 at 04:09 PM

    I've cloned your form and was performing some tests, this seems to happen due to the 0 at the beginning, upon removing it, the condition was saved successfully: 

    15926834061.gif

    I noticed that I originally added that 0 to the conditions, this is not actually required, I added it only to show the months with a single number such as "9" as "09", but you can remove it. 

    Let us know if you need further assistance. 


  • Profile Image
    manager5land
    Answered on June 20, 2020 at 04:27 PM

    Kevin,

    I understood your text writing, but I didn't understand who's form you included?

    Tks.

  • Profile Image
    KrisLei
    Answered on June 20, 2020 at 05:26 PM

    Hi,

    I have checked and cloned your form 201396333840150, and it seems you were able to remove the '0' on the condition as advised by my colleague and there are no errors on the conditions:

    1592687646condition.jpg

    I have also tested this condition and it seems working fine on my cloned form: 

    1592688192condition1.jpg

    Today's date: 11-16-2020 

    The new month is 1 (January)

    Kindly confirm, if you're still experiencing any issues on your form or if you need further assistance?

    Thank you, looking forward to your response.

  • Profile Image
    manager5land
    Answered on June 20, 2020 at 06:28 PM
    "First Payment Due Date" is working perfectly.
    Could you please help me adjust the "Last Payment Due Date". This field should be showing the results of "First Payment Due Date" + "Term (months)", minus 1 month.
    It appears January- October is working correctly, but November- December isn-t working correctly.
    ⁣Thank you,
    Chris
    ...
  • Profile Image
    KrisLei
    Answered on June 20, 2020 at 08:20 PM

    It seems we need to add a new field, to calculate for the Last Payment Due Date and I also think that this requires conditions to come up with the correct date. 

    Let me get back to you shortly. Thank you. 

  • Profile Image
    KrisLei
    Answered on June 20, 2020 at 11:12 PM

    Apologies for the delay.

    "First Payment Due Date" + "Term (months)", minus 1 month.

    Basically the Last Payment Due Date is based on the Terms (months) field because the count starts from the New Date including the number of Terms, correct? 

    I added 3 fields:

    1. For the sum of the First Payment's Month and Terms (months) - I have used the Number Field element so that we can use the greater than, less than, and equal conditions later.

    2. Last Payment Month - to show the calculation results for the month

    3. Last Payment Year - to show the calculation results for the year

    1592707413last payment.jpg

    Then here are the conditions:

    1.  IF Terms (month) field is filled it will start to calculate the First Payment's Month + Terms (months) field or the field 1 based on the screenshot above :

    1592707633condition.jpg

    2. Then I set the following conditions based on the First Payment's Month + Terms (months) field. These conditions are to calculate for the month and year of the last payment:

    There are 3 conditions for the Last Payment Month field:

    1592707915condition2.jpg

    These conditions are to calculate the corresponding month for the Last Payment Due Date minus the one month.

    There are also 3 conditions for the year:

    1592708243condition3.jpg

    Then the next step is to concatenate these values or strings on the Last Payment Due Date field, similar to the method you've used on the First Payment Due Date:

    1592708867Conditions.JPG

    Feel free to clone and run some test on my cloned form: https://form.jotform.com/201716340302945 

    Please do get back to us and let us know if it didn't meet your requirements.



  • Profile Image
    manager5land
    Answered on June 22, 2020 at 12:58 PM

    Thank you for your help. I was able to accomplish what I needed.

    Thanks, Chris