Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / September 2004



Tip: Looking for answers? Try searching our database.

Problem with CreateODBCDateTime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deaner@DM - 29 Sep 2004 15:44 GMT
I'm having problems inserting a Date and Time into a Microsoft Access 2000
Database field that is formatted as 'DateTime'. Here's some sample code of what
I'm trying:

<cfset DateTime = CreateODBCDateTime(Now())>

<cfquery name="InsertOrder" datasource="#Request.MainDSN#">
INSERT INTO Orders(
  OrderDate
)
VALUES(
  '#DateTime#'
)
</cfquery>

If I take a look at the variable DateTime it contains "{ts '2004-09-29
15:16:54'}".
Is it supposed to have the curly braces and 'ts' prefix? Access2000 certainly
won't accept it. Can anyone point out what I'm doing wrong?

Thanks in advance,

Dave
RayT - 29 Sep 2004 17:27 GMT
Yes, it is supposed to have curly braces. That is a correct ODBC DateTime.

What kind of error are you getting?

Changing to text will not work properly for dates as you will have problems
ordering and getting parts of the dates.
Deaner@DM - 30 Sep 2004 08:49 GMT
Here's the Error Message I'm getting:

Error Executing Database Query.
 
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
Access Driver] Syntax error (missing operator) in query expression ''{ts
'2004-09-30 08:47:20'}''.  
 
The error occurred in *********************: line 11
 
9 : )
10 : VALUES(
11 :   '#DateTime#'
12 : )
13 : </cfquery>

 
Thanks for the replies,

Dave
robing@pmva.com - 30 Sep 2004 09:15 GMT
Take the single quotes off the date variable...
VALUES(
#DateTime#
)
Deaner@DM - 30 Sep 2004 10:09 GMT
Thanks, schoolboy error!

In my defence I did try this and got another unrelated error, but didn't read
the actual error message and so assumed it was the same one. (Not much of a
defence I know) I have it sorted now though.

Thank you kindly,

Dave
Deaner@DM - 30 Sep 2004 10:09 GMT
Thanks, schoolboy error!

In my defence I did try this and got another unrelated error, but didn't read
the actual error message and so assumed it was the same one. (Not much of a
defence I know) I have it sorted now though.

Thank you kindly,

Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.