I'd use the standard python datetime.timedelta, to wit:
stuff = db.executesql("SELECT logstuff, logtime FROM logtable WHERE logstuff LIKE '%" + request.something )
newstuff = db.executesql("SELECT logstuff, logtime FROM logtable WHERE id ==" + id )
if stuff:
stuffdelta = newstuff[0][1] - stuff[-1:][0][1]
if (stuffdelta < datetime.timedelta(minutes=10)):
res2 = db.boottable.insert(stufftime=now, time2stuff=stuffdelta.total_seconds)
If you need it in the query, I've used something like (but I'm not, now):
results = db.executesql("SELECT * FROM logtable "
"where logtime < date('now','-0 day') ",
"ORDER BY logtime DESC ;")
(that's for sqlite, but other DBs should have something similar)
I'd think your calculations to be along those lines, give or take a few details.
/dps