Ask a Question related to Coldfusion Database Access, Design and Development.
-
mcalpin #1
IIF in Select Query Error
Hello,
I need to create a query with a date calculation of elapsed minutes. And, I
have made this work. Now I find that some of the calculations come up with
large negative numbers since one of the values may be "1800-01-01 00:00:00.0".
I am attempting to add the IIF syntax to make the resultant value equal zero if
the calculation was a negative number. But, I am getting a syntax violation at
the "<" character. Any ideas?
Thanks!
-------------------------------------------
<cfquery name="qryGetDay" datasource="MyDatasource">
SELECT RADIONAME, DISPDATE, DISPDATE, RTQDate, IIF(DateDiff("n", DISPDATE,
RTQDate) < 0, 0, DateDiff("n", DISPDATE, RTQDate)) AS TotalMins
FROM DBTable
WHERE DISPDATE BETWEEN #CreateODBCDateTime(GetDateBegin)# AND
#CreateODBCDateTime(GetDateEnd)#
AND RADIONAME IN ('#Replace(UnitList, ",", "','", "All")#')
ORDER BY RADIONAME
</cfquery>
mcalpin Guest
-
Query of Query to select a title first letter
The column "title" exists in a normal query. Need to select the first letter of the titles to build a list for a prev-next alphabetical search. ... -
Select query
I would like to perform select on the following two tables, tblPoll PollID tblPollResults PollID AnswerID UserID -
update and insert query error, but select works ok.
:rose; Any ideas spring to mind about the following issue? I'm getting an error trying to run an Update or Insert query. I can run a Select... -
SELECT query Error, possible date problem?
Hello, I have what I thought was a fairly straight forward date based query that is returning an error I cant seem to get past. Here is my... -
SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id, -
TA-Selene #2
Re: IIF in Select Query Error
The problem is that IIf is a ColdFusion function. You need to use logic that
works with your database. If you are using SQL Server, the following should
work instead:
CASE WHEN DateDiff(minute, DISPDATE, RTQDate) < 0 THEN 0 ELSE DateDiff(minute,
DISPDATE, RTQDate) END
Luckily, SQL Server has a DateDiff function as well.
TA-Selene Guest
-
mcalpin #3
Re: IIF in Select Query Error
That worked (the crowd goes wild). Thanks a lot! John
mcalpin Guest



Reply With Quote

