Forums

PHP

This topic is locked

automatically delete a record after a year

Posted 24 Nov 2004 16:05:27
1
has voted
24 Nov 2004 16:05:27 Judy Wert posted:
Has anyone set a record to delete after time? I would like to have my users be able to click a button on the input form to delete the record after a year, or archive the record after a year.

Replies

Replied 26 Nov 2004 13:18:47
26 Nov 2004 13:18:47 Simon Martin replied:
Let me start by confessing that I don't know php.

That being said, most of this would be best be done in the database.
I would add a datestamp to your table (call it dateAdded or something) - in the database set the default value as the system current date, in sql server GETDATE(), so when your records are added the date and time is recorded automatically.

SQL Server also uses the DATEDIFF function and you could set up a job that checks for records where the difference between the inserted date and the current date is 1 year and then either deletes the record or marks it as archived depending on the preference set by the user on the input form, (which would need to be stored in the database also)

Live the life you love
Love the life you live

Simon

[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]

Reply to this topic