• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

sql date format

New Here ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

Hi i have just changed my database from access to mysql, i have a insert action page which inserts a date and time

now i have converted this insert is erroring there must be a different way with sql of inserting a date ?

'#DateFormat(Now()) & ' ' & TimeFormat(Now())#'

can anyone help
TOPICS
Advanced techniques

Views

348

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

Use <cfqueryparam cfsqltype="cf_sql_timestamp" value="#yourDateHere#">

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

As a general rule, it is better to use db functions than cf functions in situations like this. I don't use mysql myself, so I don't know if it has a function that returns the current date and time. But if it does, you should use it.

If not, use the cf createodbcdatetime function, not dateformat.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

> As a general rule, it is better to use db functions than cf functions in
> situations like this.

Sorry, yes, agreed. If I was setting the CURRENT date, I'd use a DB
function to do it. If I was setting any other date, I'd use <cfqueryparam>
to pass it.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

> I don't use mysql myself, so I don't know if it has a
> function that returns the current date and time.

There's a swag of stuff here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

LATEST
In answer to your actual question, and in a summary of the others, you should have been using CreateODBCDDateTime whether using Access or SQL or any other database... it looks like before it was being put into a text field since you had quotes around it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation