We help IT Professionals succeed at work.

query of queries problem

I am trying to create a coldfusion query of queries but the dates

does not seems to be working. I am getting the error message
Query Of Queries syntax error.
Encountered "DATEDIFF ( d ,. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,

Select * from myQuery where 0=0 and DATEDIFF(d, '11/22/2012', '12/07/2011') <= 0

Comment
Watch Question

DateDiff is probably not available in QofQ as it's a database specific function

Try putting the dateDiff inside your main SELECT statement to show the number of days difference

 select dateDiff(d,createdDate,getDate())  as NumberDays

then in your QofQ you can just check the number of days column...

 where numberOfDays <= 0

erikTsomikSystem Architect, CF programmer

Author

Commented:
I am trying to run
Select *,( (param 1) ) AS target_date,dateDiff(d,11/22/2012,getDate()) as num from myQuery.

And I get an error message
Query Of Queries syntax error.
Encountered "(. Incorrect Select Statement, Expecting a 'FROM', but encountered '(' instead, A select statement should have a 'FROM' construct.
Most Valuable Expert 2015

Commented:
(no points)

> And I get an error message

Right. Like gdmaria said, you can't use DateDiff in a QoQ.  It's not a supported.

If you need to use dateDiff, you'll have to move it into your main databasequery instead.

Move this

   ,dateDiff(d,11/22/2012,getDate()) as num

Into your "MyQuery" 's select statement, don't do it in the query-of-query...


Actually, you don't need the database at all for this... it's a static state and current date.  Just do a cfset..

 <cfset days = dateDiff("d", "11/22/2012",  now())>