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   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 answers 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 Tips for writing a graduate school Personal...   |   Has anyone used a Dyson, or the DC07? Newer »
This thread is closed to new comments.