Comparing Dates in Flex.

December 10, 2008

They are many versions out there to do this, but my version is here. It’s pretty simple, clean and easy.

Check the code Example below::

var strDate1:String=”01/04/2008″;
var strDate2:String=”31/03/2009″;
var strMyDate:String=”10/12/2008″;
if(DateField.stringToDate(strMyDate,’DD/MM/YYYY’)>=DateField.stringToDate(strDate1,’DD/MM/YYYY’)
&& DateField.stringToDate(strMyDate,’DD/MM/YYYY’)<=DateField.stringToDate(strDate2,’DD/MM/YYYY’))
{
trace(“Date is in Financial Year Range”);
}
else
{
trace(“Date is not in Financial Year Range”);
}

Here iam using the DateField Class and its methods.

Enjoy the Post.