Date math in flex is poorly supported, and very inaccurate it seems. Flex might be a language on the way out but for posterity sake and any legacy code which might hang around, please do not use the accepted answer by user1196374. Their answer is rough and very inaccurate.
Below I have included code I developed to perform the stated goal, which had initially used his code in this post as a starting point.
Disclaimer, I don't know if this covers every flaw in the previous function, nor do I know if it will handle other calendars well. It is however a vastly better solution than the accepted answer.
public static function dateDiff(dateA:Date, dateB:Date): int{
var retVal:int = 0;
if(dateA != null && dateB!=null) {
retVal = roughDateDiff(toMidnightFromUTCDate(dateA),toMidnightFromUTCDate(dateB));
}
return retVal;
}
private static function roughDateDiff(dateA:Date, dateB:Date): int{
var retVal:int = 0;
if(dateA != null && dateB!=null){
if(dateA.time > dateB.time){
var dateDiff:Number = dateA.time - dateB.time;
retVal = Math.floor((dateDiff/86400000));
}else{
var dateDiff:Number = dateB.time - dateA.time;
retVal = Math.floor((dateDiff/86400000));
}
}
return retVal;
}
private static function toMidnightFromUTCDate(pre:Date):Date{
var post:Date = new Date(pre.toUTCString());
post.setUTCHours(0);
post.setUTCMinutes(0);
post.setUTCSeconds(0);
post.setUTCMilliseconds(0);
return post;
}