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 Hidden Date Field With Current Year

    Asked by bmanfield on July 11, 2015 at 08:06 PM

    Hi,

    I am developing a form that calculates a person's age on new years eve of the current year. The EOY date field is only used for calculation and therefore will be hidden. Is there any way to dynamically set the year field for the date to the current year so that the form doesn't have to be updated each year whilst maintaining static values for day and month? (31 December)

     

    Thanks

    Ben

    date field hidden hidden date current
  • Profile Image
    JotForm Support

    Answered by Mike_G on July 12, 2015 at 02:32 AM

    I'm not sure exactly how you would like your form be used. But you can use the Date field and set the Default Date to the Current Date. By doing that the Date field changes every day. The Default date is equivalent to the date on your device or your computer, where the form is opened. 

    Eventually, the date field will be 12/31/CurrentYearHere

    You'll just have to subtract the Person's Birthday from the Current Date. (use another Date field to get the Person's Birthday) Divide the difference by 365.25 days to get Age. Also, get the Floor value of the Age so that its value will be rounded to the nearest integer. Use this guide: Form-Calculation-Math-Function-Reference

    Here's the form I have used for my example: http://form.jotformpro.com/form/51921351271953

    Please feel free to clone it for your reference. 

    I hope this helps. Let us know if you need further assistance. Thank you. 

  • Profile Image
    JotForm Support

    Answered by Mike_G on July 12, 2015 at 02:44 AM

    I would like to apologize. I have mistakenly used the Math Function Floor(). You can remove that and instead use this workaround to remove the decimal places on the Person's Age Value. 

    Thank you. 

  • Profile Image

    Answered by bmanfield on July 12, 2015 at 04:02 AM

    I'm looking to have a static defined date that is 31 December YYYY where YYYY is dynamically populated. Otherwise I have to update the form annually to match the current year. I'm not sure if you can define it using something like 31/12/{dateField:year} or using #year_1?

    Its not that huge if I have to manually update it but it makes the form robust.

  • Profile Image
    JotForm Support

    Answered by Mike_G on July 12, 2015 at 04:33 AM

    Unfortunately, this: {dateField:year} is not working with conditions. But I was able to think of a way to get the current year only and place it on a field. However, this, of course, still involves a Date field with Default Date set to Current Date.


    Since, I think, you only need to get the current year and the year of the Person's birthday to get the age. I have extracted both years from their corresponding Date field and get the difference. 

    Try playing with this form by cloning it. 

    http://form.jotformpro.com/form/51918717550965

    If you change the Current Date Field's Year, the year on the New Year's Eve field will also change.

    Meaning, every year the Date on the New Year's Eve field will change automatically. 

    Let us know if this works for you. Thank you. 

  • Profile Image

    Answered by bmanfield on July 15, 2015 at 10:46 PM

    Since, I think, you only need to get the current year and the year of the Person's birthday to get the age. I have extracted both years from their corresponding Date field and get the difference.

    I'll have a look and see if it meets my needs. I'm not sure it will as I need to calculate their age on New Years eve based upon their DOB.

    eg: Players registering for 15 years and under can be > 15yo but not 16 as of the end of the current year. (31 December)

    Thanks.

  • Profile Image

    Answered by bmanfield on July 15, 2015 at 11:01 PM

    What is the difference using 0 decimal places instead of the floor() function?