1 Reply Latest reply on Feb 11, 2015 3:05 AM by Suresh

# Age related problem

### Title

Age related problem

### Post

FMP 13 Server

Using a calculation field kindly donated by someone to calculate the age of a child based on date of birth and a "Today" field.

Date of Birth and Today are in the format dd/mm/yyyy (for Australian audiences)

The calculation steps seem to want them in mm/dd/yyyy which is obviously giving me weird answers.  I will paste the calculation below if anyone could help me that would be greatly appreciated.

GetAsText(Year(Today) - Year(Date of Birth) - Case(GetAsNumber(Today)< Date(Month(Date of Birth);Day(Date of Birth); Year(Today)); 1; 0)) & " Years, " & GetAsText(Mod(Month(Today) - Month(Date of Birth) + 12 - Case(Day(Today) < Day(Date of Birth); 1; 0); 12)) & " Months, " & GetAsText(Day(Today) - Day(Date of Birth) + Case(Day(Today) >= Day(Date of Birth); 0; Day(Today- Day(Today)) < Day(Date of Birth); Day(Date of Birth); Day(Today- Day(Today)))) & " Days"

• ###### 1. Re: Age related problem

Hi Peter,

As per my suggestion u set two variables that one for 'Year', another one for 'Cyear' and one field 'Age'.
Here the 'Year' means input Birth date for the Baby, which as MM/DD/YYYY, Cyear used for Calculation. 'Age' is the output. Now set like below on a Script,

SetVariable[\$\$year; Value:Year ((TableName::DateOfBirthField))]
SetVariable[\$\$Cyear; Value:Year (Get ( CurrentDate ) )]
SetField[TableName::Age; \$\$Cyear-\$\$year]

Now use the Set Script Trigger option > Choose 'OnObjectSave' > Click the above Script Name and save, then Run it.

Hope it works.. Good luck!!