# Add a datetime field to your model that saves current datetime db.define_table('mytable', Field('firstn', 'string', length=15), Field('fdate', 'datetime', default=request.now, requires= IS_NOT_EMPTY() ) ) db.tbtime5.firstn.requires=IS_NOT_EMPTY() db.tbtime5.fdate.requires=IS_NOT_EMPTY()
# You may want to look at the underlying DATE functions of your database. # This example uses mysql and calculates the age of a record in minutes mysql> select firstn, fdate , now(), round( (time_to_sec( now() ) - time_to_sec(fdate) ) / 60, 0) as mins from mytable; +----------+---------------------+---------------------+------+ | firstn | fdate | now() | mins | +----------+---------------------+---------------------+------+ | kris | 2010-10-08 04:53:27 | 2010-10-08 05:53:24 | 60 | | joe | 2010-10-08 04:55:29 | 2010-10-08 05:53:24 | 58 | | ed | 2010-10-08 04:57:42 | 2010-10-08 05:53:24 | 56 | | greg | 2010-10-08 05:50:35 | 2010-10-08 05:53:24 | 3 | | tom | 2010-10-08 05:51:32 | 2010-10-08 05:53:24 | 2 | | bob | 2010-10-08 05:53:15 | 2010-10-08 05:53:24 | 0 | +----------+---------------------+---------------------+------+ 7 rows in set (0.00 sec) Once you've tweaked your code to delete based on minutes, modify it to work based on days. On Oct 7, 1:26 pm, ceriox <cer...@gmail.com> wrote: > Hi all, > > it is possible delete a record if it is older than 5 days (without > user operation)? > > i have a table with a data field if this field is older than 5 days i > wanna delete it and do other stuff without any "manual" operation