cfquery - selecting records where DateDiff >=0
I am trying to query a database and only show the records that are not set to expire. When I run a DateDiff on the table I pull up all records, although one of them is a -1 when you do the comparison. Here's a rought breakdown of the query.
<!--- create variable with current date --->
<cfset DaNow=#Dateformat(now(),'mm/dd/yyyy')#>
<!-- grab records that have yet to expire --->
<cfquery name="test" datasource="TestDB">
SELECT * FROM adVerts
WHERE (DateDiff('d',#DaNow#,EndDate) >=0) AND (AdType = 'BigBox')
</cfquery>
I have three records that come back as -1, 220, 150.
I can use the CFIF tag to eliminate the -1 by doing a <CFIF #DateDiff('d,DaNow,EndDate)# LT 0> tag but would like to know how to filter out the expired records via CFQUERY.
Any help would be GREATLY appreciated!
