On Tuesday, June 23, 2015 at 11:52:17 AM UTC-7, Niphlod wrote:
>
> although not in the book, epoch() is a method of a datetime field.
>
> http://pydal.readthedocs.org/en/latest/_modules/pydal/objects.html#Expression.epoch
>

Thanks for the pointer.  There is interesting stuff to explore there.

 

>
> That being said, if I got the requirements properly, which is to craft a 
> select on a datetime field for anything comprised from 5 minutes ago and 
> now, I don't get the intricacies...
>
> (db.table.field < request.now) & (db.table.field > request.now + 
> datetime.timedelta(minutes=5))
>
> doing something like the requirement strictly on a time field (i.e. 
> missing the "date" part) doesn't make any sense on the behalf of date 
> arithmetics: the only exception would be any run in the 23:55 to 00:00 
> frame, which you can account with the simplest of the if statement. Don't 
> overcomplicate a simple requirement.
>

Yes , datetime.timedelta() is a Good Thing (tm).   The entire datetime 
library module is a Good Thing (tm).  As an excuse, I offer that I was 
distracted by looking up "epoch".

/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.

Reply via email to