Handling date stored in a nvarchar field
Hi,
The values to one of our existing tables' field is saved like this.
<cfset mydatetime = createodbcdatetime(now())>
<cfdump var="#mydatetime#">
<cfquery .... >
INSERT INTO yourTable (Columnname)
VALUES (#myDateTime#)
</cfquery>
The problem is that datatype of the field is nvarchar instead of date time. So the data is saved like a string {ts '2012-04-27 13:01:18'}.
While retreiving the data, it seems difficult to do any date operations on this field like datediff.Tried to manage with convert function like this
in the select query
'DATEDIFF(M,getdate() ,CONVERT(VARCHAR(50), ,mydatetime ) , 121))',but didn't work out.
How can we handle this?
