Populate custom date on date field through update field condition
-
nlpmarinAsked 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: Conditional Logic for Online Forms
-
DavidAnswered on April 02, 2015 at 05:19 PMJotform Support
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.
-
nlpmarinAnswered 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!
-
EltonAnswered on April 02, 2015 at 11:57 PMJotform Support
@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!
-
nlpmarinAnswered on April 03, 2015 at 02:25 PM
Thank you very much, @EltonCris.
-
JonathanAnswered on April 03, 2015 at 04:05 PMJotform Support
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.
-
nlpmarinAnswered 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.
-
MikeAnswered 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.
-
nlpmarinAnswered 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.
-
JonathanAnswered on April 04, 2015 at 07:24 PMJotform Support
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.
-
nlpmarinAnswered 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!
-
JonathanAnswered on April 04, 2015 at 08:59 PMJotform Support
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.
-
nlpmarinAnswered 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).
-
nlpmarinAnswered 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!
-
DavidAnswered on April 09, 2015 at 03:53 PMJotform Support
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.
-
nlpmarinAnswered on April 10, 2015 at 03:47 AM
It appears to work perfectly now. Thank you!
-
KadeJMAnswered 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!
-
betsayAnswered on May 01, 2015 at 05:59 PM
-
raulAnswered 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.