EnjoySharePoint YouTube Channel

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010


This InfoPath SharePoint tutorial explains, how to calculate age based on a date of birth in date picker in InfoPath 2010 in SharePoint 2010.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

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.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

2. Design the InfoPath form as below:

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

3. Right-click the “Age” TextBox and make it read-only.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

4. Select the Date of Birth Control in the InfoPath 2013 form.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

5. Select the Manage rule from the ribbon in the InfoPath form.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

6. Add a new Action.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

7. In the Action select “Set A field’s Value”.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

8. In the field select “Date of Birth”.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

9. In the value select the function icon.

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

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:

Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010
Calculate Age based on Date of Birth in date picker in InfoPath in SharePoint 2010

You may like following InfoPath SharePoint tutorial:

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.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Sagar Pardeshi

I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.

View all posts by Sagar Pardeshi →