Oops, yes, the subtraction should be reversed.
But one of the overloads of the Date constructor takes a single argument, the number of milliseconds from the reference date, the same reference date as the getTime() method. The doc example shows this method for adding time to a date, but I expect it will work for subracting time as well. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Doug Lowder Sent: Tuesday, October 02, 2007 3:37 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Return a person's age Wouldn't that produce a negative number, given that birthDate probably comes before todayDate? Discounting that, I think that would give you the person's age in milliseconds. --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > Based on my reading of the docs, there is a simpler way: > > var age = new Date(birthDate.getTime() - todayDate.getTime); > > Untested. > > Tracy > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of JRBower > Sent: Tuesday, October 02, 2007 2:29 AM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: Re: [flexcoders] Return a person's age > > > > > Doug, > Thank you. I will give your code a go. :) > > Best Regards, > James > > Doug Lowder wrote: > > > > Here's how I would do it: > > > > var age:Number = todayDate.fullYear - birthDate.fullYear; > > if (todayDate.month < birthDate.month || (todayDate.month == > > birthDate.month && todayDate.date < birthDate.date)) age--; > > return age; > > > > > > -- > View this message in context: > http://www.nabble.com/Return-a-person%27s-age- <http://www.nabble.com/Return-a-person%27s-age-> tf4545118.html#a12993386 > <http://www.nabble.com/Return-a-person%27s-age- <http://www.nabble.com/Return-a-person%27s-age-> tf4545118.html#a12993386> > > Sent from the FlexCoders mailing list archive at Nabble.com. >