InfoPath: Calculate Age based on Date of Birth date picker.

I needed to calculate the age of a person to run some validation rules on my form. This is how I did it:

  • Create a Date Picker field (I named mine Birth Date) and place it on the form.
  • Create a Number field (I named mine Age.) You don’t have to place it on the form, though you can initially to make sure it is working.
  • Put the following rules on the Birth Date field:

Rule 1

Condition:
None

Action:
Set a field’s Value

Field:
Age

Value (click the fx button):
(substring(today(), 1, 4) – substring(Birth Date, 1, 4)) – 1 * (translate(substring(today(), 6, 5), “-“, “”) < translate(substring(Birth Date, 6, 5), “-“, “”))

* Birth Date is the name of your Date picker field.

 

Rule 2

Condition:

Age  is less than 0  ( should look like Age>0 when you hit ok)

Action:

Set a field’s Value

Field:

Age

Value:

0

 

There ya have it. This should give you the correct calculation.

This entry was posted in InfoPath, SharePoint and tagged , , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted November 14, 2020 at 1:33 am | Permalink

    This is the appropriate weblog for anybody who desires to find out about this topic. You understand so much its virtually hard to argue with you (not that I truly would want…HaHa). You positively put a new spin on a subject thats been written about for years. Nice stuff, simply nice!

  2. Posted December 14, 2020 at 2:52 pm | Permalink

    Hi colleagues, how is everything, and what you would like to say about this article, in my view its really awesome for me.|

Leave a Reply

Your email address will not be published. Required fields are marked *