Thanks for your response jedale.
After a lot of searching and trying, here is what I have got to work. Hope it
helps you too.
Firstly, if you are wanting to use a European date format (dd/mm/yyyy) in your
Flash forms, you need to use
<CFINPUT TYPE="datefield" NAME="nameOfDate" MASK="dd/mm/yyyy"
VALIDATE="eurodate" ...... >
to get the calendar to accept and validate european dates.
Then if you want to do DateAdd or DateDiff functions, go to this link:
http://jeff.mxdj.com/dateadd_for_actionscript.htm Jeff Tapper has created a class that includes DateAdd and DateDiff, but the
implementation in CF isn't explained.
Copy the entire class from down a bit in his post into a file called
DateFunction.as and save it in the same directory as your CF Flash page. You
can now refer to his functions as DateFunction.dateDiff and
DateFunction.dateAdd.
Usage is:
DateFunction.dateDiff(datePart:String, date1:Date, date2:Date), and
DateFunction.dateAdd(datePart:String,date:Date,num:Number)
Now the dateDiff function expects to be passed two dates defined as
datefields, but I wanted to pass it two text fields holding dates, because the
routine was being called when the dates didn't have focus and so
date1.selectedDate and date2.selectedDate weren't holding the values I needed.
So I changed the first line of the dateDiff function and added a couple of
lines, so that it reads:
public static function dateDiff(datePart:String, date1:String,
date2:String):Number{
var parts = date1.split("/");
var day = Number(parts[0]);
var month = Number(parts[1]) - 1;
var year = Number(parts[2]);
var date1 = new Date(year, month, day);
parts = date2.split("/");
day = Number(parts[0]);
month = Number(parts[1]) - 1;
year = Number(parts[2]);
var date2 = new Date(year, month, day);
return getDateDiffPartHashMap()[datePart.toLowerCase()](date1,date2);
}
Then I was able to use:
var vDaysLeft =
Number(DateFunction.dateDiff("d",_root.Date1.text,_root.Date2.text));