I am getting an error when trying to insert the OCDBDateTime object into my database table.
The Table name is "Time", The field name is "Date"
Here is my code snippit:
Code:
<cfoutput>
<cfset myDate = now() />
<cfset myTableDate = #createODBCDateTime( myDate )# />
My Date: #myDate# <br/>
Table Date: #myTableDate# <br/>
<cfquery name="qrytime" datasource="exampledsn" username="exampleuser" password="password" >
INSERT INTO
Time (Date)
Value ( '#myTableDate#')
</cfquery>
<cfquery name="qryshowtime" datasource="exampledsn" username="user" password="password" >
SELECT * FROM
Time
</cfquery>
#qryshowtime.Date#
</cfoutput>
This is the error generated by the server:
[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near 'Value'.
The error occurred in TestDateTime.cfm: line 11
Called from Index.cfm: line 143
Called fromTestDateTime.cfm: line 11
Called from Index.cfm: line 143
9 : Table Date: #myTableDate# <br/>
10 :
11 : <cfquery name="qrytime" datasource="exampledsn" username="user" password="mypassword" >
12 : INSERT INTO
13 : Time (Date)
SQLSTATE HY000
SQL INSERT INTO Time (Date) Value ( getdate())
VENDORERRORCODE 102
DATASOURCE exampledsn
Resources:
I do not know why the table does not like this date/time object.
I have read that the datetime object in SQL server is like 8 characters only?
I think the error of incorrect syntax near "value" is strange?