# calculate the age

**yourspoon**Mar 19, 2012 5:17 AM

Hello,

I need to know the age of a person in years, month and days and I already found this algorithm:

* ElapsedYears (calculation, number result) = ** Year ( Get ( CurrentDate ) ) - Year ( Birthdate ) - If ( Get ( CurrentDate ) < Date ( Month ( Birthdate ) ; Day ( Birthdate ) ; Year ( Get ( CurrentDate ) ) ); 1 ; 0 )*

* ElapsedMonths (calculation, number result) = ** Mod ( Month ( Get ( CurrentDate ) ) - Month ( Birthdate ) + 12 - If ( Day ( Get ( CurrentDate ) ) < Day ( Birthdate ) ; 1 ; 0 ) ; 12 )*

* ElapsedDays (calculation, number result) = ** Day ( Get ( CurrentDate ) ) - Day ( Birthdate ) + If ( Day ( Get ( CurrentDate ) ) ≥ Day ( Birthdate ) ; 0 ; If ( Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) < Day ( Birthdate ) ; Day ( Birthdate ) ; Day ( Get ( CurrentDate )- Day ( Get ( CurrentDate ) ) ) ) )*

Since I do not need the function "CurrentDate" I changed it to this:

(note: I changend Get ( CurrentDate ) to ( Datum_Verlauf ) and Birthdate to Patient::GebDatum)

*ElapsedYears (calculation, number result)=*

*Year ( Datum_Verlauf ) - Year ( Patient::GebDatum ) - If ( Datum_Verlauf < Date ( Month ( Patient::GebDatum ) ; Day ( Patient::GebDatum ) ; Year ( Datum_Verlauf ) ); 1 ; 0 )*

*ElapsedMonths (calculation, number result) =*

*Mod ( Month ( Datum_Verlauf ) - Month ( Patient::GebDatum ) + 12 - If ( Day ( Datum_Verlauf ) < Day ( Patient::GebDatum ) ; 1 ; 0 ) ; 12 )*

*ElapsedDays (calculation, number result) =*

*Day ( Datum_Verlauf ) - Day ( Patient::GebDatum ) + If ( Day ( Datum_Verlauf ) ≥ Day ( Patient::GebDatum ) ; 0 ; If ( Day ( Datum_Verlauf ) - Day ( Datum_Verlauf ) ) < Day ( Patient::GebDatum ) ; Day ( Patient::GebDatum ) ; Day ( Datum_Verlauf ) - Day( Datum_Verlauf ) ) )*

Now it says, that there is no function "ElapsedDays"...

I'm not familiar with this type of script and I actually tought that the function "ElapsedDays" would be defined by "*ElapsedYears (calculation, number result) = *", but obviously it's not. Can you please tell me what's wrong with it? =)