The problem has a very likely cause. ColdFusion does not recognize the value of Local.TempDate as a valid date.
However a neat solution is possible. May we assume that the searched date is always going to be of the following form?
Mon Feb 29 17:00:00 AEDT 2016
If so, then I will suggest a solution that has reuse potential.
DateFromSearch.cfc
component {
public any function init (string inputDate) output=false {
/* Argument of the form: Mon Feb 29 17:00:00 AEDT 2016 */
/* In the functions below, treat date string as list with delimiter " " */
variables.dateAsString=arguments.inputDate;
return this;
}
public numeric function getDay() output=false {
var d=listGetAt(variables.dateAsString,3," ");
return d;
}
public numeric function getMonth() output=false {
var monthAsString=lcase(listGetAt(variables.dateAsString,2," "));
var mnth=0; // initialize
switch(monthAsString) {
case "jan":
mnth=1;
break;
case "feb":
mnth=2;
break;
case "mar":
mnth=3;
break;
case "apr":
mnth=4;
break;
case "may":
mnth=5;
break;
case "jun":
mnth=6;
break;
case "jul":
mnth=7;
break;
case "aug":
mnth=8;
break;
case "sep":
mnth=9;
break;
case "oct":
mnth=10;
break;
case "nov":
mnth=11;
break;
case "dec":
mnth=12;
break;
}
return mnth;
}
public numeric function getYear() output=false {
var yr=listLast(variables.dateAsString," ");
return yr;
}
}
testpage.cfm (in same directory as the CFC)
<cfscript>
Local.TempDate = ExecutedSearch["datefield_dt"][Local.i]; /* Mon Feb 29 17:00:00 AEDT 2016 */
dateObj = new DateFromSearch(Local.TempDate) ;
Local.TempDate = createdate(dateObj.getYear(),dateObj.getMonth(),dateObj.getDay());
</cfscript>