Try this.

delete  from tblEvents
where DATEDIFF(dd,estarttime , getdate()) > 7


Dave


----- Original Message -----
From: "Angel Stewart" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, April 01, 2003 9:12 AM
Subject: SQL: Deleting items older than 7 days from today


> Hey all,
>
> I'm trying to do this with a single SQL statement.
>
> Delete all records from the table tblEvents that are older than 7 days.
>
> :)
>
> This is the code I tried using:
>
> <CFQUERY name="DE" Datasource="#DSN#">
>
> Select * FROM tblEvents
> WHERE Now() - estarttime >= 7
>
> </CFQUERY>
>
> <CFDUMP var="#DE#">
>
> <CFQUERY name="DE2" Datasource="#DSN#">
>
> Select * FROM tblEvents
> WHERE #DateDiff('dd',Now(),estarttime)# GTE 7
>
> </CFQUERY>
>
> <CFDUMP VAR="#DE2#">
>
> The first query works fine...the second one throws an error:
>
> "Error Diagnostic Information
>
> An error occurred while evaluating the expression:
>
> #DateDiff('dd',Now(),estarttime)#
>
> Error near line 19, column 9.
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to