Proper formatting/need for cfqueryparam w/CF_SQL_TIMESTAMP & TimeFormat

Posted on 2010-08-14
Last Modified: 2012-06-27

I am getting the following error:

The error occurred in E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 812
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 798
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 739
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 134
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 1
810 : <cfqueryparam cfsqltype="cf_sql_integer" value="#posted_by#">,
811 : <cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#dateformat(now(), 'mm/dd/yyyy')#">,
812 : <cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#TimeFormat(Now(), 'hh:mm tt')#">)
813 : SELECT @@Identity AS MusicID
814 :

do I even need to be using the cfqueryparam?

The dateformat(now() seems to be working but not the TimeFormat(Now()

Question by:btintermedia
LVL 52

Accepted Solution

_agx_ earned 500 total points
ID: 33439296
Can you post the whole query and the error message? That snippet just shows some sort of error occurred. But not what the error is.

>> do I even need to be using the cfqueryparam?

   Technically, no. But it's a good practice for several reasons: performance, security and
   correct interpretation of date values.

>>  SELECT @@Identity AS MusicID

    For CF8+ it's better to use cfquery's result attribute to get the new ID. For other versions
    SCOPE_IDENTITY() is probably what you want instead.  @@Identity can return the wrong
    value under certain conditions.

Author Closing Comment

ID: 33462119
I determined that I was passing a wrong variable, farther back in application - but I had forgotten that I had not upgraded this code to the correct standard in terms of getting the new recordset that is generated, so I am awarding points.

thanks for you help

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server Log File Space 6 34
SSIS import multiple CSVs into associated tables 3 32
Azure SQL DB? 3 22
SQL Query for Periods 3 12
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them ( . I did keep the main js functions but made sever…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now