What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Populate custom date on date field through update field condition

    Asked by nlpmarin on April 02, 2015 at 02:48 PM

    What syntax do I use to update a date field? I would like to populate a "start date" field based on what is entered in two other fields. I understand how to phrase the conditions, but I can't figure out how to type the date in the calculation area to get the date field to display correctly. Thank you!



    This is a re-post of a comment on Smart Forms Using Conditional Logic

    date field start date start thank
  • Profile Image
    JotForm Support

    Answered by david on April 02, 2015 at 05:19 PM

    Hi,

    Depending on what you are trying to do, the date field lets you add and subtract values to update another date field.  For example, this condition:

    Would take the date in the first field, move the date forward 95 days, then insert the new date into the second date field.  Here is my test form to show you how it works:

    http://form.jotformpro.com/form/50844949917976

    http://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL

    Let us know a bit more detail about what you are trying to get working and we will be happy to help.

  • Profile Image

    Answered by nlpmarin on April 02, 2015 at 06:20 PM

    Thanks for your response.

    What do I do if I want to insert a specific date?

    For example IF Name1 IS EQUAL TO JOE, INSERT February 28, 2012 INTO Date1

    I haven't been able to figure out how to actually write the date to make that work. That's what I'm looking for, please.

    Thanks!

  • Profile Image
    JotForm Support

    Answered by EltonCris on April 02, 2015 at 11:57 PM

    @nlpmarin 

    Thanks for your clarification. After running some tests, I can confirm that it is not possible to populate custom date on the date field through update field condition. Let me add this as a feature request instead so our developers will be able to consider this in the future.

    You may consider using regular text boxes for now for prepopulating date text.

    Thanks!

  • Profile Image

    Answered by nlpmarin on April 03, 2015 at 02:25 PM

    Thank you very much, @EltonCris.

  • Profile Image
    JotForm Support

    Answered by jonathan on April 03, 2015 at 04:05 PM

    I feature request ticket had already been submitted. 

    We will let you know here for any update on the status.

    What do I do if I want to insert a specific date?

    Did you meant you want the specific date to be manually inserted?

    If you will add an input box where you wanted to insert the specific date, you should be able to use it to manually update/populate the Start Date also.

    If you do not want to have a manual input field to add the specific custom date (if you want all manual input to happen on hidden condtion logic only), you can also just used the Calculation as described already by our colleague David previously.

     

    Please try my example jotform http://www.jotformpro.com/form/50926177000953

    The calculation condition I setup is like this

    it works like this

     

    as you can see, to have the specific date, you can just indicate a +/- date on the current date to indicate the exact date.

    Please let us know of your feedback on this.

    Thanks.

     

     

  • Profile Image

    Answered by nlpmarin on April 03, 2015 at 06:26 PM

    Hi Jonathan. Thanks for your support.

    To answer your question: No, I'm trying to avoid all manual entry of dates. I'm trying to have all date fields automatically populated based on the choice made from a menu. 

    e.g.:

    IF ClassName IS EQUAL TO ClassA

      Insert 01/01/2016 into StartDate

    IF ClassName IS EQUAL TO ClassA

      Insert 01/31/2016 into EndDate

    IF ClassName IS EQUAL TO ClassB

      Insert 02/01/2016 into StartDate

    IF ClassName IS EQUAL TO ClassB

      Insert 02/29/2016 into EndDate

    (Actually it's based on two menu choices but it the solution is the same.) 

    The only problem that I'm facing is how to type the date itself into the conditions wizard to make the dates show up properly. And that doesn't seem to be possible right now.

    I might be able to use your technique to achieve another goal later on, so thanks very much for demonstrating that.

  • Profile Image
    JotForm Support

    Answered by Mike on April 03, 2015 at 07:25 PM

    We can "populate" the DateTime field with numeric values to get the actual dates. Javascript uses 1970-01-01 date as a start point for time values, so we will need to calculate a difference in days between needed date and 1970-01-01.

    For example, use:

    http://www.timeanddate.com/date/durationresult.html

    Then, 'Update a form field value' condition:

    Form example:

    http://form.jotformpro.com/form/50927635365967

    Thank you.

  • Profile Image

    Answered by nlpmarin on April 04, 2015 at 05:40 PM

    Oh, thank you, Mike. This is heading me in the right direction. Two questions for you:

     

    Shouldn't this work? I get nothing in the target field (Start Date). It remains empty.

     

    It seems to be one day off in your example:

     

    Is that normal? Do we just have to add one to correct it?

    Thank you.

  • Profile Image
    JotForm Support

    Answered by jonathan on April 04, 2015 at 07:24 PM

    Please take note that to get the correct number of days (result), the Start Date to should always be 1/1/1970 (January 1, 1970 or the Epoch Time reference)

     

    If you checked the conditional statement set in Mike_T's sample form http://form.jotformpro.com/form/50927635365967

    the correct number of days to calculate was set similarly to what was calculated in the date calculation tool.

     

    when I checked the sample form of Mike_T, it was calculating correctly and filling the Date field with the correct date.

    From what I understand in your screenshot, the exact date you wanted to assign is September 18, 2015 -- which is 16696 days from 1/1/1970

     

    I applied the same calculation using a clone of Mike_T's sample form http://form.jotformpro.com/form/50937356457970?

     

    and it is working correctly

     

    I am curious how you were able to get this screenshot

     

    was this from the test form http://form.jotformpro.com/form/50927635365967 ?

    It is weird that we have different result.

     

    Hope this help. Let us know if still not resolved.

    Thanks.

     

     

     

  • Profile Image

    Answered by nlpmarin on April 04, 2015 at 07:57 PM

    Thank you for your response. Yes, that screen shot is from the same test form, and it still shows me a day off. Strange.

    I decided to go a slightly different route with my form, but am still using date insertions from conditions rules.

    Would you please check my form in your browser to see if your dates are the same as the ones I see? http://form.jotform.us/form/50906777138161

    Here is what you should see if you enter "CCB 02" into "Event Code":

    The title and dates should fill automatically.

    Thank you!

  • Profile Image
    JotForm Support

    Answered by jonathan on April 04, 2015 at 08:59 PM

    When I checked your jotform http://form.jotform.us/form/50906777138161 I again got the result off by a day compared to your result.

     

    It is now obvious that the difference was due to the location time zone difference.

    My current location time zone is GMT +800 while you seems to be at EST.

    I could not figure out yet how to overcome the difference and make it use a specific/fixed time zone. 

    But the good thing here is, there is no issue in your current form conditional statement. So, it should be good as is by now.

    I will search more how to go about the different time zone issue. We will update you here once we got a resolution for it.

    Thanks.

     

  • Profile Image

    Answered by nlpmarin on April 04, 2015 at 09:03 PM

    Interesting! I don't see how that would account for it, but I will have some people near me test it find out if it's just me or my system.

    Thanks for looking into it further. I am in Pacific Daylight Time (GMT -7).

  • Profile Image

    Answered by nlpmarin on April 09, 2015 at 02:44 PM

    That is excellent! Much easier!

    However, I am having the problem of the dates showing up one day off each time they are inserted on this form: http://form.jotform.us/form/50906777138161

    The field called "Event Code" creates the conditions to auto-fill the start and end dates (among other fields).

    Here are some of the possibilities:

     

    Using "MST 20" as an example, this is the result:

     

    See how the dates are one day early?

    What's more, the Start Date is also to be inserted into the "First payment due" field:

    And that one is showing up an additional day early!

    Please advise. Thank you!

  • Profile Image
    JotForm Support

    Answered by david on April 09, 2015 at 03:53 PM

    I opened this ticket again so that the developer may have a look.  We will update you here as soon as we have any further information.

  • Profile Image

    Answered by nlpmarin on April 10, 2015 at 03:47 AM

    It appears to work perfectly now. Thank you!

  • Profile Image
    JotForm Support

    Answered by KadeJM on April 10, 2015 at 09:52 AM

    Terrific! Thanks for the update about and we're glad to know it's now working great for you! 

  • Profile Image

    Answered by betsay on May 01, 2015 at 05:59 PM

    Hi what about for the time, I'd like when when I select an option in the dropdown automatically the time will be populated as well. for example I select 12 hours on the drop down, I want the time to automatically adjust itself and add current time + 12 hours.
     
  • Profile Image

    Answered by raul on May 01, 2015 at 07:02 PM

    @betsay

    Your question has been moved to a separate thread here: http://www.jotform.com/answers/562974
    We'll be attending it as soon as possible.