the doc is rather incomplete. Either you want a set of distinct things, or you want to aggregate something over a group of distinct things.
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()) On Tuesday, January 27, 2015 at 10:25:40 AM UTC+1, Moiz Nagpurwala wrote: > > > I found this code in web2py documentation: > > for row in db().select( > db.entries.ALL, > orderby=~db.entirs.Date, groupby=db.entirs.Date): > print row.name > > > How to amend this code to select distinct years from a date field. > > Please help. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

