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.
How do I Create a dynamic date?Asked by bmanfield on November 21, 2015 at 01:23 AM
I'm not sure if this is possible currently so this is why I ask. :)
I need to create a date for calculations based upon a specific roll over date in the future for the current year. Currently I have to statically define the future date that becomes invalid once the date passes. Is there any possibility that the date field can be augmented to allow the date's year, month or day to be defined dynamically?
In my form I have to calculate the age of a participant based upon their age at the end of the calendar year.
I want to set a date field as 31/12/YYYY to allow me to calculate ages as of that date in the current year. This year it would be 31/12/2015. Next year it would automatically be 31/12/2016. It makes the form more robust if the dynamic date is able to pick up the YYYY from the current year.
Or is it less effort to just manually update the hidden field periodically?
dynamic date substring widget dates year birthday birth year age
The only way that we can get the Year only from the Date field is with the help of a few text fields and the Substring widget.
Here's a sample form: https://form.jotform.com/53246757477973
In the sample form, all of the other fields should be read-only except for the date fields so the conditions will work. And aside from the Birthday field and Age field all of the other fields should be hidden. The Substring widget can be hidden with the help of CSS injected in the form.
Here are the conditions:
If "Birthday" field is filled then its value will be passed to "Get Birthday in DDMMYYYY format" field. This is important so that any input on the "Birthday" field with an incorrect format like 1-1-2015(January 1, 2015) instead of 01-01-2015 will be corrected when transferred to the "Get Birthday in DDMMYYYY format" field.
If "Get Birthday in DDMMYYYY format" field is filled, pass its string format to "Birthday String correct format" field.
Then we will use the string format value of "Birthday String correct format" field on the Substring widget(Get Birth year).
If "Birthday String correct format" field is filled then it will pass the value of the Substring widget to the "Birth Year" field.
If "Birthday" is filled, pass its string format to "Current Date String correct format" field.
Same as the above, we will use the string format value of "Current Date String correct format" field on the Substring widget(Get Current year)
We will then pass the value of the Substring widget(Get Current year) to the "Current Year" field if any of the rules is met.
Since we have the birth year and the year of the current year. Create a condition that gets the age by subtracting the two.
I would suggest you clone the sample form above using this guide: How-to-Clone-an-Existing-Form-from-a-URL to inspect the fields and the conditions.
I hope this helps. Let us know if you need any further assistance or clarification with any of the instruction given above. Thank you.
Yeah I was right - too hard! :-D
Plus the age needs to be calculated at a specific date and not purely based upon year alone which is why I want to inject the year in a date field.
But thanks for taking the time to explain it all. I'll certainly bookmark it for my 'To Do' list.
On behalf of my colleague Mike_G, you are welcome. If you have any further questions, please feel free to contact us. Regards.