Solved

QofQ Date Convert Error

Posted on 2003-12-02
3
197 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

22 Experts available now in Live!

Get 1:1 Help Now