Ask a Question related to Coldfusion Database Access, Design and Development.
-
Niles Runeberg #1
Query - Datediff problem
Hello all,
I am trying to generate a list of users that have not responded to a survey in
3 months, but I am running into problems with the query...
I am using Access and here is my query...
<cfquery name="get_people" datasource="#Application.dsn#">
SELECT *
FROM contact
WHERE survey_type = 2
AND #dateDiff("m", Now(), datelast_responded)# <= 3
ORDER BY lname ASC
</cfquery>
I get the error [Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
What am I doing wrong??
Niles Runeberg Guest
-
Datediff() bug
The Datediff("m",startdate,enddate) function does not return the correct value if the startdate is "2/28/05" and the enddate has a day value of... -
Datediff Problem
I am having some difficulties with the function Datediff! I am trying to calculate the number of days between two given date E.G: Number days... -
DateDiff Problem with the Year 2000
I am having a problem calculating the proper age of people if they were born in the year 2000 <cfset bydate=#dateformat(#todaydate#,"mm/dd/yy")#>... -
DateDiff problem on different servers
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to... -
Using DatePart and DateDiff together in a query
Does any one know how I would go about using DatePArt and DateDiff in the same query for the same field? For example, I need to get the amount of... -
jdeline #2
Re: Query - Datediff problem
Try pulling the DateDiff function out of the WHERE clause and assign it to a
variable. Use that variable in your WHERE. If the problem is in the DateDiff
function, the error will be thrown on the assignment.
jdeline Guest
-
Mountain Lover #3
Re: Query - Datediff problem
WHERE survey_type = 2 AND DateDiff('m', Now(), datelast_responded) <= 3
HTH
--
Tim Carley
[url]www.recfusion.com[/url]
[email]info@NOSPAMINGrecfusion.com[/email]
Mountain Lover Guest
-
Niles Runeberg #4
Re: Query - Datediff problem
Originally posted by: jdeline
Try pulling the DateDiff function out of the WHERE clause and assign it to a
variable. Use that variable in your WHERE. If the problem is in the DateDiff
function, the error will be thrown on the assignment.
But that would require another query wouldn't it? The variable
datelast_responded is coming right from the database...
Niles Runeberg Guest
-
Niles Runeberg #5
Re: Query - Datediff problem
That doesn't work either... it doesn't limit the dates properly, the output has
an entry from today in there which means the datediff did not work.
I can use a cfif later down the page to filter the results, but that is not
good code.
Niles Runeberg Guest
-
Mountain Lover #6
Re: Query - Datediff problem
What?
A datediff <= 3 months ('m') is going to include today, especially since
you are using Now(). Why would you think it should not?
--
Tim Carley
[url]www.recfusion.com[/url]
[email]info@NOSPAMINGrecfusion.com[/email]
Mountain Lover Guest
-
Mountain Lover #7
Re: Query - Datediff problem
If you don't want today, then you will need to use days ('y') and maybe
even Now()-1 and then test for <= 90
HTH
--
Tim Carley
[url]www.recfusion.com[/url]
[email]info@NOSPAMINGrecfusion.com[/email]
Mountain Lover Guest
-
mxstu #8
Re: Query - Datediff problem
Niles,
Are you trying to retrieve a list of users that last responded to a survey
over three months ago? So if today is 08/19/2005, you want people that last
responded prior to 05/20/2005? Sssuming your date column contains only a date
and not a date and time (ex. '2005-05-19 13:57:46'), you try something like the
query below. You may also want to check for null dates, to find users that
never responded at all.
---- example
SELECT (SomeColumns)
FROM contact
WHERE survey_type = 2
AND datelast_responded <= #CreateODBCDate(dateAdd("m", -3, now()))#
ORDER BY lname ASC
<!--- the query above translates to
......
WHERE survey_type = 2 AND datelast_responded <= {d '2005-05-19'}
--->
mxstu Guest



Reply With Quote

