How can I use ColdFusion 5 to insert a date and time into a SQL Server 2000 datetime field?
January 5, 2004 12:01 PM   RSS feed for this thread Subscribe

How can I use ColdFusion 5 to insert a date and time into a SQL Server 2000 datetime field? [more inside]

Here's my code:

<cfset modStartTime = CreateDateTime(2004,04,17,modStartHour,form.startMinute,00)>
<cfset modEndTime = CreateDateTime(2004,04,17,modEndHour,form.endMinute,00)>

<cfset EventStartTime = CreateODBCTime(modStartTime)>
<cfset EventEndTime = CreateODBCTime(modEndTime)>

<cfquery name="addEvent" datasource="calday">
INSERT INTO Events(EventStartTime,EventEndTime)
VALUES(<cfqueryparam value="#EventStartTime#" cfsqltype="CF_SQL_DATE">,
<cfqueryparam value="#EventEndTime#" cfsqltype="CF_SQL_DATE">
)
</cfquery>
posted by kirkaracha to computers & internet (2 comments total)
So what's the problem? I'm not in front of my cf server, but I don't see anything obviously wrong with your code. Is there an error?

Or is this all just part of a new answer-my-own-question MetaAskMetafilter ;) ?
posted by mkultra at 3:31 PM on January 5, 2004


I was getting a data conversion error. I eventually got it to work by changing CF_SQL_DATE to CF_SQL_TIMESTAMP (even though the SQL field is not a timestamp) and changing EventStartTime to:
<cfset EventStartTime = "2004-04-17 #modStartHour#:#form.startMinute#:00">
posted by kirkaracha at 4:35 PM on January 5, 2004


« Older I'd like to hear some tips inv...   |   After living together for four... Newer »
This thread is closed to new comments.


Related Questions
How can I get back up to speed on basic CSS and... June 23, 2008
ColdFusion SQL Injection Attack Terror October 22, 2007
Latecomer to Open Source Programming April 20, 2007
Help me find a menu that doesn't suck April 5, 2007
How can I export data from SQL Server 2000 to... February 5, 2004