stookie
Posts: 5
|
Posted: 08/01/2008, 6:15 AM |
|
Hi Forum
I am trying to get the code that will delete records that have a date field older than 2 days from today's date.
The code I have been trying to use is:
DELETE FROM k-events WHERE date_start < date() -2
I have been searching around the forum and tried several variations this code... just cant get it to work!.
I know it's just a simple code but just cant get it.
Any help on this matter would be appreciated, Thanks
|
|
|
Oper
Posts: 1195
|
Posted: 08/02/2008, 8:43 AM |
|
Database?
generic:
DELETE FROM Table WHERE datediff(date1,date2) < 2 (or whatever)
function datediff may vary from one database to another
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
Tuong Do
|
Posted: 09/07/2008, 9:29 PM |
|
For Microsoft Access
DELETE FROM k-events WHERE date_start < DaysAdd(day , -2 , date() )
For MS SQL
DELETE FROM k-events WHERE date_start < DaysAdd(day , -2 , getdate() )
"stookie" <stookie@forum.codecharge> wrote in message
news:648930c8b61458@news.codecharge.com...
> Hi Forum
>
> I am trying to get the code that will delete records that have a date
> field
> older than 2 days from today's date.
>
> The code I have been trying to use is:
> DELETE FROM k-events WHERE date_start < date() -2
>
> I have been searching around the forum and tried several variations this
> code... just cant get it to work!.
>
> I know it's just a simple code but just cant get it.
>
> Any help on this matter would be appreciated, Thanks
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
|