<p>What is the best way to calculate Age using Flex?</p>

I found an answer at
the bottom of this page in comments section (which is now offline)
.
jpwrunyan said on Apr 30, 2007 at 10:10 PM :
By the way, here is how to calculate age in years (only) from DOB without needing to account for leap years:
With a slight correction by
Fine-Wei Lin
, the code reads
```
```
private function getYearsOld(dob:Date):uint {  
    var now:Date = new Date();  
    var yearsOld:uint = Number(now.fullYear) - Number(dob.fullYear);  
    if (dob.month > now.month || (dob.month == now.month && dob.date > now.date)) 
    {
       yearsOld--;
    }
    return yearsOld;  
}
```
```
This handles most situations where you need to calculate age.