Both of the approaches you suggested are not yielding any results.
> given that db.entries.date is a datetime field, the former is fetched with > > db(db.entries.id > 0).select(db.entries.date.year(), distinct=True) > > while the latter, e.g. the entry count per year, with > > sum_of_entries = db.entries.id.count() > db(db.entries.id > 0).select(sum_of_entries, db.entries.date.year(), > groupby=db.entries.date.year()) > > I tried assigning the results of the query to a variable and display it in a view, which does not work. In Controller: def year(): years = db(db.mydiary.id > 0).select(db.mydiary.Date.year(), distinct= True) return locals() In View: <div class="well"> {{=BEAUTIFY(years)}} {{=years}} </div> the variable is printed twice purposely. -- 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/d/optout.