Could be wrong, but... local.qry_getLogindate['logindate'] is an array, not the date value you think it is.
Try local.qry_getLogindate['logindate'][1] or local.qry_getLogindate.logindate instead. Adrian > -----Original Message----- > From: marc -- [mailto:[email protected]] > Sent: 18 March 2009 13:08 > To: cf-newbie > Subject: CF does not recognize a datetime value as date > > > Hi all, > > I have a problem using a datetime value from a mssql2008 db in a > coldfusion datediff function. I insert a datetime value in a datetime > field > > Here is what I do: > > 1) Insert date: > > <cfquery name="local.qry_insert" datasource="#VARIABLES.dsn#"> > INSERT INTO logins( > userid, > logindate, > loginip) > VALUES( > <cfqueryparam value="#arguments.userid#" > cfsqltype="cf_sql_varchar" maxlength="55">, > <cfqueryparam value="#NOW()#" cfsqltype="cf_sql_timestamp" > maxlength="50">, > <cfqueryparam value="#CGI.REMOTE_ADDR#" > cfsqltype="cf_sql_varchar" maxlength="39"> ) > </cfquery> > > 2)Retrieve the date: > > <cfquery name="local.qry_getLogindate" datasource="#VARIABLES.dsn#"> > SELECT logindate FROM logins WHERE userid=<cfqueryparam > value="#arguments.userid#" cfsqltype="cf_sql_varchar" maxlength="55"> > </cfquery> > > <!--- check if logindatetime has not expired > <cfif local.qry_getLogindate.RecordCount gt 0 AND DateDiff("n", > ParseDateTime(local.qry_getLogindate['logindate']),NOW()) lte 5> > <cfset local.result = true> > </cfif> > > This gives me > <h3>Application Execution Exception</h3> > > <strong>Error Type: </strong> Expression : [N/A]<br /> > <strong>Error Messages:</strong> > Complex object types cannot be converted to simple values.<br /> > > If i want to check if qry_getLogindate['logindate'] evaluates to a > datetime value I get > > "2009-03-18 13:03:42.053" > > If I want to check if qry_getLogindate['logindate'] is a date by > IsDate(qry_getLogindate['logindate']) > it returns > "NO" > > All this is in coldbox v 2.6.2, CF8 and the function is called via > jQuery Ajax calls. > The functions shown above are not directly called by the javascript - > they are in the model layer > > When I check if what i want to do is valid _at all_ I try this in a > .cfm page: > > DateDiff("n", "2009-03-18 11:45:03.913", NOW())=#DateDiff("n", "2009- > 03-18 11:45:03.913", NOW())# > outputs > DateDiff("n", 2009-03-18 11:45:03.913, {ts '2009-03-18 13:04:45'})=79 > > Why can't I use a datetime value in a datetime CF function???? > > Marc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4457 Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
