Mostly a note to self for future reference. Not quite an implementation of the much loved datediff function, but close enough to get what I want:
The caveat here of course is that the date’s have to be after 1970, else the getTime() call won’t work.
// yearValue, monthValue, dayValue are assumed to be populated by the UI somewhere
startDate:Date = new Date(yearValue, monthValue, dayValue)
seconds:Number = ((new Date()).getTime() - startDate.getTime())/1000;
differenceInYears:Number = seconds / 60 / 525948.766; // google says a year is 525,948.766 minutes
Every language should have a date difference function and the ability to handle timespans as native types.