Ask a Question related to Coldfusion Database Access, Design and Development.
-
Buddhatech74 #1
Date insertion problems MySQL
I am currently trying to update a mysql database with a date entered using a
form. However when I look at the database the date always reads 1/1/0001.
I tried locally with debugging on and the date is getting submitted as fom
data. Look like this 03/09/2005
Here is my code:
<cfquery datasource="dumped">
UPDATE dumped SET dumpdate=
<cfif IsDefined("FORM.dumpdate") AND #FORM.dumpdate# NEQ "">
#FORM.dumpdate#
<cfelse>
NULL
</cfif>
Any help would be great!
Buddhatech74 Guest
-
Mysql Date Problem
Hi, I am trying to get the date from a MYSQL server into a PHP page I am creating with Dreamweaver, I create a new recordset and go to advanced and... -
CFMX blob insertion to MySQL
I am trying to use CFMX to store a binary (blob) into a MySQL db. Using MySQL Control Center (GUI interface to the db), I have manually placed a... -
PHP Date into MySQL
Hi, I have the following script that is installed to obtain the date 7 days into the future and display 1 weeks worth of dates (minus Sunday). I... -
date mysql
Hi I have troubles with converting a date value to unixtime! In mysql I have a table named date TYPE "DATE" (2003-09-05) Now I want it to convert... -
DATE insertion
Hi all, First of all, thanks to everyone who helped me with the "checkbox" issue. I have an issue here while trying to INSERT INTO a MySQL table... -
philh #2
Re: Date insertion problems MySQL
Budd, Check out the function CreateODBCDateTime(). It may help you here.
Also, if FORM.dumpdate is in the format mm/dd/yyyy or dd/mm/yyyy, surround it
with single quote marks (or, for Access, the dreaded pound sign). HTH,
philh Guest
-
Buddhatech74 #3
Re: Date insertion problems MySQL
Ok So I took some of your suggestions and I think I am closer. Thank you. Here
is my code now:
<cfquery datasource="dumped">
UPDATE dumped SET dumpdate=
<cfif IsDefined("FORM.dumpdate") AND '#FORM.dumpdate#' NEQ "">
#DateFormat(CreateODBCDate(FORM.dumpdate), "dd/mm/yyyy")#
<cfelse>
NULL
</cfif>
and here is whats being submitted:
SQL Queries
(Datasource=dumped, Time=0ms, Records=0) in
C:\Inetpub\wwwroot\dumped\dumpeeinfo.cfm @ 14:02:24.024
UPDATE dumped SET dumpdate=
22/03/2005
, besttime=
NULL
, customermessage=
NULL
Keep in mind the date is coming from one field in my form.
Thanks for any help I can get.
Buddhatech74 Guest
-
philh #4
Re: Date insertion problems MySQL
Yup, almost there. <cfquery datasource='dumped'> UPDATE dumped SET dumpdate=
<cfif IsDefined('FORM.dumpdate') AND '#FORM.dumpdate#' NEQ ''>
#DateFormat(CreateODBCDate(FORM.dumpdate), 'dd/mm/yyyy')# <cfelse> NULL
</cfif> Now, surround the date value with single quotes: <cfquery
datasource='dumped'> UPDATE dumped SET dumpdate= <cfif
IsDefined('FORM.dumpdate') AND '#FORM.dumpdate#' NEQ ''>
'#DateFormat(CreateODBCDate(FORM.dumpdate), 'dd/mm/yyyy')#' <cfelse> NULL
</cfif> I don't know what your flavor of DB accepts for date delimiters, so
YMMV. HTH,
philh Guest



Reply With Quote

