In this post we will discuss how to calculate age based on date of birth in date picker in InfoPath in SharePoint 2010.
Also you can check out:
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.
2. Design the form as below:
3. Right-click the "Age" TextBox and make it read-only.
4. Select the Date of Birth Control.
5. Select the Manage rule from the ribbon.
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:
The age field should now be populated with an amount 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.