Thanks Massimo. That worked like a charm. I guess that's where a good general understanding of the Python language comes in handy. I need to dig into a good reference manual for sure.
-Eric On Oct 22, 10:27 am, mdipierro <[email protected]> wrote: > You cannot you must use a range, define > > today=datetime.datetime > (request.now.year,request.now.month,request.now.day) > tomorrow=today+datetime.timedelta(days=1) > > and use this query: > > (db.sale.timestamp>=today)&(db.sale.timestamp<tomorrow) > > On Oct 22, 8:51 am, emaynard <[email protected]> wrote: > > > I am trying to create a query that will show a running list of log > > entries for the current day. I have reviewed the web2py docs and the > > Python Datetime object documentation, but a working solution continues > > to elude me. > > > Here is a snippet of my model: > > > db.define_table('item', > > Field('barcode','string'), > > Field('name','string'), > > Field('unit_cost','double'), > > Field('unit_price','double') > > ) > > > db.define_table('sale', > > Field('location_id','reference location'), > > Field('timestamp','datetime',default=now, readable=False, > > writable=False,), > > Field('item_id','reference item'), > > Field('qty','integer') > > ) > > > And here is the snippet of code from the controller where I attempting > > to query and total a running list of the number of items sold on a > > given day. > > > todays_trans = (db.sale.item_id == db.item.id) & (db.sale.timestamp > > == datetime.date.today()) > > return dict(form=crud.create(db.sale), > > sales=db(db.sale.item_id == db.item.id).select(limitby=(0, > > 15), orderby=~db.sale.timestamp), > > daytotal=db(todays_trans).select(db.item.name, > > db.sale.qty.sum(), groupby=db.sale.item_id) > > ) > > > I can not seem to get the second part of the todays_trans WHERE > > statement to properly filter for just the current days sales entries. > > > I have tried (db.sale.timestamp.date() == datetime.date.today()) , but > > that just throws this error: > > > "...AttributeError: 'Field' object has no attribute 'date'..." > > > Obviously, there is something that I missing concerning accessing the > > date portion of my sales table's timestamp field, but I can't find the > > answer. > > > Any ideas? > > > -Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

