Thanks for trying to help 
I can't compare the db.table.field (in my case db.checkpoint.check_time) to 
request.now because request.now is a datetime and the field i compare with 
 is only time
therefore I have to construct a datetime before I compare but can't do it 
because the DAL will not accept an expression made of the field and an 
offset added to it.
To clarify the requirements:  the value I want to compere with is being use 
cyclically every day. For example  if the fields value is 13:42 that's mean 
that everyday around 13:42
I have to do something. Example: send mail if no order was received  from 
specific customer in the last 180 minutes period which is a parameter of 
the checkpoint.  So I run a periodic task (no request object but this is 
another story, I get the current time from the datetime.datetime.now()) 
that retrieves the checkpoints every few minutes  and the checkpoints are 
pointing to customers, from which I takes the the number of orders and the 
mail address, Each checkpoints has a period. 
I wish it was simpler but how else I can do it ?
Thanks for your patient

On Tuesday, June 23, 2015 at 8:52:17 PM UTC+2, 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
>
> 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.
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to