This InfoPath SharePoint tutorial explains how to calculate a person’s age (in years) given his/her date of birth in InfoPath 2010 in SharePoint 2010. It can be done without writing even a single line of code.
New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features
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 like below in InfoPath form.
5. Select the Manage rule from the ribbon in the InfoPath form.
6. Add a new Action rule in InfoPath form.
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:
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:
- How to show calculated date in a field in Infopath SharePoint 2010?
- Add multiple lookup columns to SharePoint list InfoPath form
- Validate email address in InfoPath 2010
- Phone number validation in InfoPath 2010
- Zip code validation in InfoPath 2010
- How to hide ribbon in InfoPath 2010 in SharePoint 2010?
- Add fields to a library after a form has been published in Infopath SharePoint 2010
- Make attachment field mandatory in InfoPath Designer 2013 in SharePoint Online list
- Unable to connect SharePoint site. The Operation could not be completed error in InfoPath 2013 SharePoint Online
The age in years will be displayed depending on the selected Date of Birth in InfoPath form in SharePoint 2010.
FREE SHAREPOINT 2019 PDF
(Installation & Features)