[web2py] REF: Finding if a date is between two date fields

2014-02-05 Thread Teddy Nyambe
I would like to find out how to achieve this comparison:

row = db(db.mytable.start_date  today  db.mytable.end_date).select()

I am getting this error:

Traceback (most recent call last):
  File
/Users/teddyl/PycharmProjects/website/web2py/gluon/contrib/shell.py, line
234, in run
exec compiled in statement_module.__dict__
  File string, line 1, in module
TypeError: can't compare datetime.date to Field

But if I try:

row = db(db.mytable.start_date == today).select()

This comparison works, is there another way of doing it?

-- 
...
Teddy Lubasi Nyambe

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


Re: [web2py] REF: Finding if a date is between two date fields

2014-02-05 Thread Johann Spies
Try

query = db.mytable.start_date  today  db.mytable.end_date  today
row = db(query).select()

This works for me:

surveylist = [(x.id, x.name) for x in db(
(db.survey.startdate = today)
(db.survey.enddate = today)).select(db.survey.id,
 db.survey.name)]


Regards
Johann



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

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