def datesearch():
    matches=None
    form =
SQLFORM.factory(Field('start_date','date',requires=IS_NOT_EMPTY()),
 
Field('end_date','date',requires=IS_NOT_EMPTY()))
    if form.accepts(request.vars,session):
        (sy,sm,sd) = (int(x) for x in form.vars.start_date.split('-'))
        (ey,em,ed) = (int(x) for x in form.vars.end_date.split('-'))
        query = (db.things.created_on >= datetime.date(sy,sm,sd)) &
(db.things.created_on <= datetime.date(ey,em,ed))
        matches = db(query).select()
    allrows = db().select(db.things.ALL)
    return dict(form=form,matches=matches,allrows=allrows)



On Feb 27, 9:00 pm, Thadeus Burgess <[email protected]> wrote:
> #and
> db(db.table.field >= '2009-12-28')(db.table.field <= '2009-12-30').select()
> #or
> db(db.table.field == '2010-01-01' | db.table.field == request.now).select()
>
> db(db.table.field.year() > '2008').select()
>
> db(db.table.field.day() < '5').select()
>
> -Thadeus
>
> On Sat, Feb 27, 2010 at 3:52 PM, Stelios Koroneos
>
> <[email protected]> wrote:
> > Hi, I'm trying to make a query function that accepts two datetime.date
> > object(start_date and end_date), and returns all records that are
> > between start_date and end_date.
> > However, I found nothing like a between function in the web2py manual,
> > so I was wondering what's the best way to achieve this.
> > I tried using the db.table.field.year(), db.table.field.month() and
> > db.table.field.day() but that would create a rather complex solution
> > --
> > Stelios S. Koroneos
>
> > Digital OPSiS - Embedded Intelligence
>
> > Tel +30 210 9858296 Ext 100
> > Fax +30 210 9858298
> >http://www.digital-opsis.com
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" 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 
> > athttp://groups.google.com/group/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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.

Reply via email to