Not possible. You can only do
query=(db.my_table.start_date>=current_date - datetime.timedelta
(days=30) )
the left hand side of a "left op right" query has to be a field, not
an expression. The right hand side can be an expression but you cannot
mix python functions and sql functions.
Massimo
On Jun 22, 2:59 pm, Jose <[email protected]> wrote:
> Hello
>
> How do I solve this query?
>
> db.define_table('my_table',
> SQLField('start_date', 'date'),
> SQLField('ndays', 'integer'),
> ...
> )
>
> def my_function():
> import datetime
>
> current_date = datetime.date.today()
>
> #Option 1
> query=(db.my_table.start_date + db.my_table.ndays >= current_date)
>
> #Option 2
> query=(db.my_table.start_date + datetime.timedelta(days=30) >=
> current_date)
>
> #Option 3
> query=(db.my_table.start_date + datetime.timedelta
> (days=db.my_table.ndays) >= current_date)
>
> rows = db(query).select()
> return dict(rows=rows)
>
> Always ignores the added to the date. The option 3 obviously produces
> a mistake.
>
> Jose
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---