3 Replies Latest reply on Jan 12, 2010 10:05 AM by Francisc

    Date difference

    Francisc Level 3

      Hello!

       

      I have this dateDifference function:

       

      public static const millisecondsPerDay:int=86400000;//=1000*60*60*24;

      private function dateDifference(start:String,end:String):uint

      {

           var startDate:Date=new Date(start.substr(0,4),start.substr(4,2),start.substr(6,2));

           var endDate:Date=new Date(end.substr(0,4),end.substr(4,2),end.substr(6,2));

           return Math.ceil((endDate.getTime()-startDate.getTime())/millisecondsPerDay);

      }

       

      The problem is when I input dateDifference('20100227','20100301') the result is 5 instead of 3. February 2010 has 28 days so: 27,28,01 is 3 days.

       

      Any ideas?

       

      Thanks!