4 Replies Latest reply on Jun 19, 2010 7:29 PM by FMNewbie

# Age calculations

### Title

Age calculations

### Post

(FileMaker Advanced 11 on Mac OS Snow Leopard)

I have read several posts about calculating age using the current date and the date of birth by subtracting one from the other which returns a value equal to the number of days which, if divided by 365 will give you the number of years.  Simple enough... but my database will have entries for adults, children and infants.  I have been trying to figure out how write a script that will use CurrentDate and DateOfBirth to enter a value in CurrentAge as either:

(a)  an age in years if they are older than 2 yrs old with the text "years old" appended to it

(b)  an age in months if they are between 1 month and 2 yrs old with the text "months old" appended to it

(c)  an age in days if they are a newborn less than 1 month old  with the text "days old" appeneded to it

Any suggestions??   I'm still getting my head around scripting and I'd appreciate any input.  Thanks!!  :)

• ###### 1. Re: Age calculations

Use a CASE function in your CurrentAge calculation field with the needed statements from the link above.

all the best.

• ###### 2. Re: Age calculations

Try =

```Let ( [
today = Get ( CurrentDate) ;
m = 12 * ( Year ( today ) - Year ( DOB ) ) + Month ( today ) - Month ( DOB ) - ( Day ( today ) < Day ( DOB ) )
] ;
Case (
m ≥ 24 ; Div ( m ; 12 ) & " years old" ;
m ; m & " months old" ;
today - DOB & " days old"
)
)```

Note that "month" is a rather flexible term. This calculation assumes that a person becomes a month older on the same day-in-month as his birthday or when the month ends - whichever happens first. The side effect of this is that some people become 1 month old after being 30 days old, others after 29 or 28 or even 27.

• ###### 3. Re: Age calculations

I'd forgotten how much I love this stuff.  It's like figuring out a puzzle or a mystery.

Good luck,

V.

• ###### 4. Re: Age calculations

Wow... thanks "Comment"!!   That works perfectly.    :robotvery-happy: