Calculate Age in Year in InfoPath Form in SharePoint 2010


This article explains how to calculate a person’s age (in years) given his/her date of birth in InfoPath in SharePoint. It can be done without writing even a single line of code.

Read some SharePoint 2013 tutorials below:

What we need to do?
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.


infopath sharepoint Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
2. Design the form as below:
infopath sharepoint 2013infopath sharepoint Calculate Age in Year in InfoPath Form in SharePoint 2013
infopath sharepoint 2013 Calculate Age in Year in InfoPath Form in SharePoint 2013
3. Right-click the “Age” TextBox and make it read-only.


infopath sharepoint online Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
4. Select the Date of Birth Control.
infopath sharepoint 2016 Calculate Age in Year in InfoPath Form in SharePoint 2016
Calculate Age in Year in InfoPath Form in SharePoint 2016
5. Select the Manage rule from the ribbon.
infopath 2013 tutorial sharepoint Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
6. Add a new Action.
infopath 2013 tutorial sharepoint: Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
7. In the Action select “Set A field’s Value”.
infopath 2013 tutorial sharepoint Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
8. In the field select “Date of Birth”.
infopath 2013 tutorial sharepoint: Calculate Age in Year in InfoPath Form in SharePoint 2019
Calculate Age in Year in InfoPath Form in SharePoint 2019
9. In the value select the function icon.
infopath sharepoint 2010: Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
10. Add the following formula:
number(substring(today(), 1, 4)) – number(substring(., 1, 4))
11. Finally you will get the preview as below:
infopath sharepoint 2010 Calculate Age in Year in InfoPath Form in SharePoint 2010
Calculate Age in Year in InfoPath Form in SharePoint 2010
Result
The age in years will be displayed depending on the selected Date of Birth.

You May Also like the Following SharePoint Online Tutorials:

Leave a Reply