Check out Best Alternative to InfoPath -> Try Now
This InfoPath SharePoint tutorial explains, how to calculate age based on a date of birth in date picker in InfoPath 2010 in SharePoint 2010.
Use rules, conditions, the today() function, the number() function, and the substring() function in InfoPath to calculate a person’s age from his/her date of birth.
We only need to use rules, conditions, the today() function, the number() function, and the substring() function in InfoPath to calculate a person’s age given his/her date of birth.
Use the following procedure to do it.
1. Create a new Blank Form in InfoPath 2010.
2. Design the InfoPath form as below:
3. Right-click the “Age” TextBox and make it read-only.
4. Select the Date of Birth Control in the InfoPath 2013 form.
5. Select the Manage rule from the ribbon in the InfoPath form.
6. Add a new Action.
7. In the Action select “Set A field’s Value”.
8. In the field select “Date of Birth”.
9. In the value select the function icon.
10. Add the following formula:
The Action on the first Rule must say:
number(substring(today(), 1, 4)) – number(substring(., 1, 4))
11. Finally, you will get the preview as below:
You may like following InfoPath SharePoint tutorial:
- Change code language to C#.Net in InfoPath 2010 in SharePoint 2010
- Print multiple InfoPath form views in SharePoint
- Add multiple lookup column to SharePoint 2010 list InfoPath 2010 form
- Change different view in InfoPath 2010 based on certain condition
- InfoPath designer repeating table example
- Create Data Connection in InfoPath in SharePoint
- InfoPath cannot add the event handler error in SharePoint 2010
- Get Manager Details for Logged in User in InfoPath 2013
- InfoPath Add action rule to people picker in SharePoint 2013
- Disable Save button in list form in InfoPath 2013
- Check more than 5 conditions in InfoPath 2013 Rule
- Declare Hidden Variable in InfoPath 2013/2010
- Add hyperlink in InfoPath 2013 in SharePoint 2013
- Add Infopath form to a page in SharePoint using InfoPath Form Web Part
The age field should now be populated with a number of years when you fill out a date of birth in the InfoPath form. The age in years will be displayed depending on the selected Date of Birth in the InfoPath form field.
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.