Also, John, if you set the datatype to "timestamp" in MySQL, and set the option to update the timestamp on "update" of the record, and set the default as "CURRENT_TIMESTAMP", the timestamp field will automatically be filled in when the record is first created or updated.
You don't have to write anything in your queries. I do it this way all the time. Saves me the headache of worrying about date formatting going into the database. I just formate the date and/or time when I display the data. Rick -----Original Message----- From: Paul Kukiel [mailto:[email protected]] Sent: Saturday, August 15, 2009 10:48 PM To: cf-newbie Subject: Re: writing a date to mySQL Hi John, Did you set the type n the database to dateTime? Paul On Aug 15, 2009, at 10:30 PM, John Barrett wrote: > > I have a form, and I want to write a date entered in a DB field. > This is just being tested right now on the localhost. it seems to > only get 8 characters in the URL field. > > I tested it with test=adobe, URL = http://adobe.com, desc= adobe is > a company. > it gives me an error for MySQL and shows only http://a > > I am doing something really wrong here? I have used > the",<cfqueryparam cfsqltype="cf_sql_timestamp" value="#Now()#">" > before and it worked, but today I can't see to get this working. > > Any help would be fantastic. > > All I can think of is, that I am not using cfqueryparam for > everything, but this would not cause a MySQL error. Or that URL has > issues with he DB, but here I am just writing text. > > My Source > I have a db table test (ID, text, URL, desc, date) > I am trying to write a form to the DB, but add a date when the form > was submitted. > > my form is simple: > <cfform action="testing_action.cfm" method="post"> > <table width="630" border="0"> > <tr> > <td width="116">Text </td> > <td width="558"> <cfinput type="Text" name="text" > id="text" size="50"></td> > </tr> > <tr> > <td>URL</td> > <td> <cfinput type="Text" name="URL" id="URL" > size="50"></td> > </tr> > <tr> > <td>Discription </td> > <td><cftextarea name="desc" label="desc" > id="desc" rows="5" cols="40"></cftextarea></td> > </tr> > <tr> > <td> </td> > <td><cfinput type = "submit" name="submit" > class="button" value = "submit"></td> > </tr> > <tr> > <td> </td> > </tr> > </table> > </cfform> > > The action page: > <!--- Insert link into the database ---> > <cfquery datasource="#REQUEST.dataSource#"> > INSERT INTO test(text, URL,desc,date) > VALUES('#FORM.text#', '#FORM.URL#', > '#FORM.desc#',<cfqueryparam cfsqltype="cf_sql_timestamp" > value="#Now()#">) > </cfquery> > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4706 Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
