rss
twitter

Friday, April 17, 2009

Finding number of days between two dates in Flex

Today i found an interesting post an Flexexamples that by using simple basic arithmetic subtraction operator we can find the difference between the two different dates.
That is by subtracting one date from another date we can find out how many days are between those days.for example if you want to know the days between April 30-May28 means,just subtract April 30 from May 28 .here is the Flex code fragment to do this.

Actionscript Code:

private function calculateDays():String {
var tempDate:Date = new Date((new Date(2009,04,03)).getTime()
-(new Date(2009,03,30)).getTime());
return Math.round((tempDate.time / MS_PER_DAY) + 1).toString();
}



We can use this functionality to find the number of days in between the two selected dates in datechooser,or the days in the selected Range in Datechooser.Like that this functionality can be used where-ever the difference between the dates is needed.
Leave me a comment about this post.

Bookmark and Share

1 comments:

Anonymous,  December 15, 2010 at 8:43 PM  

Ignore spam post by Rose.

Post a Comment

  © Blogger templates by Ourblogtemplates.com updated with zenplate.com tips

Back to TOP