Configure fields in your form to automatically calculate age by subtracting birth date from the current date.
Calculate Age
It involves a little bit of creative Form Builder work on the front-end but will do all the work for you when completing a submission.
- Select + Add Field, type "Current Date," and enter.
- Select the gear icon to open Field Settings. Leave the Default Value as the Current Date, but feel free to toggle Mobile Visible off, under the More tab, to hide the field on mobile. Select Done to close the modal.
- Select + Add Field, type "Date of Birth," and enter. This time, open the Field Settings and select No Default (Blank) as the Default Value. Leave this field as Mobile Visible. Select Done to close the modal.
- Select + Add Field, type "Calculation," and enter. Now change the name to "Age in Hours."
- Open Field Settings and on the Calculation tab, expand the first Value drop down and select "Current Date," expand the second Value drop down and select "Date of Birth."
- Click the Addition symbol to expand the function drop down and select Subtraction as the function. On the More tab, toggle Mobile Visible off to keep this field from unnecessarily cluttering your form. Select Done to close the modal.
- Repeat step 4 but name the field "Age in Days." This time when setting up the calculation, select "Age in Hours" in the first Value drop down and in the second drop down, Add Constant. Type in "24" as the constant, and select Division. Hide this field on mobile as well. Select Done to close the modal.
- Repeat step 4 but name it "Age in Years." Following step 7, select "Age in Days" for the first value, and add a constant of "365.25" for the second value (the .25 takes leap years into account). This calculation also requires division. Leave this visible on mobile.
- The Format will default to 0 decimal places. It will automatically round up when there are 0 decimal places allowed, so allow at least 1 decimal for better accuracy. For example, a 26.6 output would be considered 27 without decimal places.
Save and Publish to test it on mobile.
Despite all the invisible supportive fields doing calculations in the background, the goal is for the form to still be clean and easy to read.
Did we answer your question?
Please let us know by voting below. All we ask is if you downvote, please let us know how the content can be improved in the comments!
Comments
0 commentsPlease sign in to leave a comment.