Solved

QofQ Date Convert Error

Posted on 2003-12-02
3
200 Views
Last Modified: 2013-12-24
I'm having some big problems with using QofQ on a query that has some null values for a date-based column.  If I try to do a QofQ against it it errors.  I've illustrated several different scenarios in the code below, and only one of the test cases will error.  It is the one that gets an actual SQL Date object back from ColdFusion, uses that value to build another query from scratch, and then does a QofQ against that query.

The way my code is layed out, I don't really have the ability to change the way I'm doing things (as far as building a query from scratch and then QofQ against it) without a lot of rewinding in development, which I don't really have time for.  What can be done to quickly fix this error without changing the overall structure of the code?  Please note that in production my code is doing the thing that causes the error in the code below.  Replace #dsn# with a datasource of your own.  Please note that it is SQL Server 2000.

Is this some sort of CFMX error?  Has Macromedia released a hotfix?

Thanks,

Justin


<CFQUERY NAME="testQuery1" DATASOURCE="#dsn#">
      SELECT GETDATE() as SomeDate1
</CFQUERY>

<CFQUERY NAME="testQuery2" DATASOURCE="#dsn#">
      SELECT '2001-01-01 00:00:00.0' as SomeDate2
</CFQUERY>

<CFSET SomeDate3 = "2001-01-01 00:00:00.0">

<CFSET testQ = QueryNew("numCol,dateCol,stringCol")>
<CFSET QueryAddRow(testQ)>
<CFSET QuerySetCell(testQ,"numCol",1)>
<CFSET QuerySetCell(testQ,"stringCol","First row")>

<!--- Does cause error
<CFSET QuerySetCell(testQ,"dateCol",testQuery1.SomeDate1)>
--->
<!--- Does not cause error
<CFSET QuerySetCell(testQ,"dateCol",testQuery2.SomeDate2)>
--->
<!--- Does not cause error
<CFSET QuerySetCell(testQ,"dateCol",SomeDate2)>
--->

<CFSET QueryAddRow(testQ)>
<CFSET QuerySetCell(testQ,"numCol",2)>
<CFSET QuerySetCell(testQ,"stringCol","Second row")>
<CFSET QuerySetCell(testQ,"dateCol","")>

<CFDUMP VAR="#testQ#"><BR><BR>

<CFQUERY NAME="testQuery2" DBTYPE="query">
      SELECT * FROM testQ
</CFQUERY>

<CFDUMP VAR="#testQuery2#"><BR><BR>
0
Comment
Question by:newstandard
  • 2
3 Comments
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9860331
In your actual code is this ever returning more than 1 row?

<CFQUERY NAME="testQuery1" DATASOURCE="#dsn#">
     SELECT GETDATE() as SomeDate1
</CFQUERY>
0
 
LVL 6

Accepted Solution

by:
PE_CF_DEV earned 250 total points
ID: 9860377
nevermind that Ixsee the error now..here is the fix:
<CFSET QuerySetCell(testQ,"dateCol",dateformat(testQuery1.SomeDate1)&' '&timeformat(testQuery1.SomeDate1))>
0
 

Author Comment

by:newstandard
ID: 9860419
That looks like it does fix the test code.  Hopefully it will fix the real code when I get a chance to put it in.  Thanks.
0

Featured Post

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

12 Experts available now in Live!

Get 1:1 Help Now