.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Calculate Age in Year in InfoPath Form

Posted By:abhays       Posted Date: April 30, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article, I have describe that how to Calculate Age in Year in InfoPath Form.

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

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.

Blank Form in InfoPath

2. Design the form as below:

 Design the form

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

Age Textbox

4. Select the Date of Birth Control.

Date of Birth Control

5. Select the Manage rule from the ribbon.
Manage rule from ribbon

6. Add a new Action.

Add a new Action

7. In the Action select "Set A field's Value".
fields Value

8. In the field select "Date of Birth".

Select date of Birth

9. In the value select the function icon.
Select 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:



The age in years will be displayed depending on the selected Date of Birth.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend