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

Insert current date CF & MS SQL

LEGEND ,
Jan 24, 2007 Jan 24, 2007

Copy link to clipboard

Copied

I am attempting to update a field with a current date using cfquery and SQL.
How can I do this? I tried (CurrentDate()) and Now(). The field is set to
SmallDate. Thanks!

UPDATE [Moot Court Invitation]
SET [invite?] = 1
[invitation date] = #Now()#
WHERE peopleid = '#arguments.pcode#'


TOPICS
Advanced techniques

Views

843

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
Guest
Jan 24, 2007 Jan 24, 2007

Copy link to clipboard

Copied

since you're using SQL Server, just use getDate(). it's the built in SQL Server function (the equivelant of CF's now()).

SET [invite?] = 1, [invitation date] = getDate()
WHERE peopleID = ...

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 ,
Jan 24, 2007 Jan 24, 2007

Copy link to clipboard

Copied

in mssql, I believe the name of the function is getdate.

If you want to use the cold fusion function, now(), you also have to use either cfqueryparam or createodbcdate.

Is your peopleid field char or numeric. If numeric, lose the quotes.

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 ,
Jan 24, 2007 Jan 24, 2007

Copy link to clipboard

Copied

Even funnier, both work just fine IF you add a comma after the prior column
name and value... opps.


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 ,
Jan 24, 2007 Jan 24, 2007

Copy link to clipboard

Copied

Wally Kolcz wrote:

> UPDATE [Moot Court Invitation]
> SET [invite?] = 1
> [invitation date] = #Now()#
> WHERE peopleid = '#arguments.pcode#'

btw those are awful column names.

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 ,
Jan 25, 2007 Jan 25, 2007

Copy link to clipboard

Copied

LATEST
You have no idea how bad they actually are. 🙂


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