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.
2 Comments
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!
Hi colleagues, how is everything, and what you would like to say about this article, in my view its really awesome for me.|