On Friday, June 5, 2015 at 6:32:39 AM UTC-7, 黄祥 wrote: > > it's so difficult without seeing any code, but you can use timedelta for it > e.g. not tested > duedate = blog.created_by + datetime.timedelta(7) > editable = True if request.now < duedate else False > > Note that datetime.timedelta is a Python feature, <URL:https://docs.python.org/2/library/datetime.html#timedelta-objects>
but web2py also supports time in queries. <URL:http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#year--month--day--hour--minutes--seconds> Here's a couple of posts I've made in the past about dates: <URL:https://groups.google.com/d/msg/web2py/-VPp4OaSskI/SvAfYL6yoqEJ> (does a timedelta calculation on two rows from a query), and also shows an db.executesql() with an "older than" clause) and <URL:https://groups.google.com/d/msg/web2py/MNzcV1dsgMk/1nFl__MDrMoJ> where I have a db(db.table matches month).select() that orders by the month. Hope this helps ... a lot of reading when you're starting out, eh? /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.