Ask a Question related to Coldfusion Database Access, Design and Development.
-
HeloWorld #1
createodbcdatetime() function.
Hi everyone,
if I use the following;
<cfset mydatetime = #createodbcdatetime(now())#>
and try to insert the "mydatetime" value into a MS-SQL Database, the DB throws
an error about the value not meeting the datetime columns length or some such
error.
I thought the whole idea of the createodbc function set was to create
date/time values that were DB friendly.
What am I missing??
HeloWorld Guest
-
Error when using createODBCDateTime and Now()
I'll start you guys off with my code here: <cfquery datasource="tempData"> UPDATE login SET lastLoginIP='#REMOTE_ADDR#' lastLoginDate=#Now()#... -
#25866 [Bgs]: Using error_reporting() function don't change output of phpinfo() function
ID: 25866 Updated by: sniper@php.net Reported By: sfournier at dmsolutions dot ca Status: Bogus Bug Type: ... -
#25866 [Opn->Bgs]: Using error_reporting() function don't change output of phpinfo() function
ID: 25866 Updated by: sniper@php.net Reported By: sfournier at dmsolutions dot ca -Status: Open +Status: ... -
note 33575 added to function.register-shutdown-function
If your script exceeds the maximum execution time, and terminates thusly: Fatal error: Maximum execution time of 20 seconds exceeded in - on line... -
note 33132 deleted from function.register-shutdown-function by sniper
Note Submitter: markus@malkusch.de ---- I can't agree with nick at nickjoyce dot com. I use php 4.2.3 on linux and my shutdown function is... -
Dan Bracuk #2
Re: createodbcdatetime() function.
I never use the createodbcsomething functions. I always do this sort of thing,
and I probably have the wrong timeformat.
datetimestring = dateformat(now(), "yyyy-mm-dd" & " " & timeformat(now(),
"HH:MM:ss";
(should resemble 2005-09-06 20:53:00)
Then in the query, do something like this:
insert into thetable
(datetimefield, etc)
values
( {ts '#datetimestring#'}, etc)
Dan Bracuk Guest
-
HeloWorld #3
Re: createodbcdatetime() function.
Originally posted by: Dan Bracuk
I never use the createodbcsomething functions. I always do this sort of
thing, and I probably have the wrong timeformat.
datetimestring = dateformat(now(), "yyyy-mm-dd" & " " & timeformat(now(),
"HH:MM:ss";
(should resemble 2005-09-06 20:53:00)
Then in the query, do something like this:
insert into thetable
(datetimefield, etc)
values
( {ts '#datetimestring#'}, etc)
Using your code and adding in the "{ts...} " is the problem I am having.
the "{ts}" needs to be removed from the string prior to being inserted into
the MS-SQL db, otherwise it fails.
HeloWorld Guest
-
mxstu #4
Re: createodbcdatetime() function.
Originally posted by: HeloWorld
Using your code and adding in the "{ts...} " is the problem I am having.
the "{ts}" needs to be removed from the string prior to being inserted into
the MS-SQL db, otherwise it fails.
I've used createODBCDate() and createODBCDateTime() with MS SQL for years and
it works fine. Although, Dan Bracuk's date format looks pretty similar to
ODBC format. Just make sure you're not putting single quotes around the
variable values. It should look something like this
<!--- don't need # pounds signs around the CF functions --->
<cfset mydatetime = createodbcdatetime(now())>
<cfquery .... >
INSERT INTO yourTable (someDateColumn)
VALUES (#myDateTime#)
</cfquery>
mxstu Guest
-
HeloWorld #5
Re: createodbcdatetime() function.
Seems that I should take myself out the back and slap me around a little.....
I am not too sure how it works, but it does....
Ultimately , I believed it wasn;t working due to the following.
when I CFOUPUTted the variable, it displayed as {ts'sxxxx'}
I tried ti cut/paste THIS value directly into the SQL database (for testing to
see if it worked!)
which it didn't.
performing a SQL insert, somehows strips out the {ts' '} and just leaves
you with the date/time.
HeloWorld Guest
-
mxstu #6
Re: createodbcdatetime() function.
I think that's what everyone thinks the first time they see that funky date/time format... "This can't *possibly* work right..." ;-)
mxstu Guest



Reply With Quote

