I'm struggling to
get the difference between two dates in months...
I want to input
something like Jan 1st and July 18th, and get something like 7.5
out.
I tried using
.getTime() and then creating a date from the result, but that's not accurate
because of variable length months. I then wrote the below, but it only works for
whole months (and I need decimals).
It would've taken me
seconds in C# (DateTime - DateTime = Timespan), but I can't find any useful
methods in Flex. Am I missing something simple?
if (startDate >
endDate)
{
var tmp:Date = endDate;
endDate = startDate;
startDate = endDate;
}
var numMonths:Number = 0;
while (startDate <= endDate)
{
numMonths++;
trace(startDate.month);
if (startDate.month == 12)
{
trace("reset");
startDate.fullYear++;
startDate.month -= 12;
}
else
trace("inc");
startDate.month++;
}
return numMonths;
{
var tmp:Date = endDate;
endDate = startDate;
startDate = endDate;
}
var numMonths:Number = 0;
while (startDate <= endDate)
{
numMonths++;
trace(startDate.month);
if (startDate.month == 12)
{
trace("reset");
startDate.fullYear++;
startDate.month -= 12;
}
else
trace("inc");
startDate.month++;
}
return numMonths;
The information contained in this e-mail and/or any attachments is confidential and intended only for the individual(s) to which it is addressed. If you are not named as an addressee you must not disclose, copy or take any action in reliance of this transmission. This e-mail and its attachments have been scanned for viruses by MessageLabs Ltd.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

