Isn't now() a function in mySql too? So you could just do .....


<CFQUERY NAME="qnews" DATASOURCE="#dsn#" USERNAME="#un#"
PASSWORD="#pw#">
    INSERT INTO guide (title, content, update)
             VALUES ('#title#', '#content#', now())
</CFQUERY>


Should work.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 20 February 2004 10:40
To: CF-Talk
Subject: Re: mySQL date ?


right but thats the thing, i figured i could just use Now() and
didnt
think twice about it, until i ran it & it choked. U'd think that
would be
properly formated

so when i use
<!--- do insert now --->
<CFQUERY NAME="qnews" DATASOURCE="#dsn#" USERNAME="#un#"
PASSWORD="#pw#">
    INSERT INTO guide (title, content, update)
             VALUES ('#title#', '#content#', #Now()#)
</CFQUERY>

i get

Error Executing Database Query.
Syntax error or access violation: You have an error in your SQL
syntax.
Check the manual that corresponds to your MySQL server version
for the
right syntax to use near 'update) VALUES ('dddddd', 'dsfdfdfdsf
f',
'2004-0


> [EMAIL PROTECTED] wrote:
>> thanks but already been there.. done that
>>
>> in access i would set the db asa date/time and use either
Now() or
>> Date() as the default and it was fine but mysql when i do
that enters
>> the words not the values
>>
> I'm not sure what you're getting at here.  Are you saying that
in the
> database you've said use now() as the default?  If so, then
yes I've
> seen this issue too, but never persued it and just ended up
inserting it
>
>   as part of the query rather than try to default it in the
database.
>
> I'm using mySQL, I have datetime and date fields in multiple
tables.  I
> use CreateODBCDateTime, CreateODBCDate and CF Now() as well as
the mySQL
>  now() function to insert dates/datetime into the database.
>
>
>
>> however, i didnt know that reserve words mattered in
variables to, i
>> thought it was just the db field names themselfs, are u sure
bout
>> that? doesnt seem right to me.
>>
> Strictly speaking no it doesn't matter, but it is good
practice.
>
>
>> im using the field as an int because it works with the php
(choke)
>> date inserts using time()
>>
> Hmmm... Dates and times do end up as purely a number when you
get into
> the lower levels of the database, which might well be
seconds-from-epoch
>  as Tom suggests, or a Julian date. Generally speaking though,
you give
> the database an appropriately formated date/time to a
date/time field,
> it stores it any way it feels like, but returns the data in
date/time
> format and allows you to index/search that data as a
date/time.
>
>> that example i put up was just the last 1 i tried. i looked
on google
>> and didnt find an answer but saw some stuff about how it goes
into the
>> db must be a certain way.
>>
>> but u'd think it wouldnt be a problem to just set the now()
variable
>> and insert it but its choking. u'd think it would be a snap
maybe its
>> just my ghost in the machine again
>>
>
> As Tom says now() returns an ODBC formated Date/time object.
> Unfortunately, there are no functions in CF to do what Tom
suggests, but
>  I'm sure it possible to work it out, if you really need
to.....
>
>
> Regards
>
> Stephen
>
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to