it's the same "method" as extrapolating the "count()" part....
year_part = db.mydiary.Entry_Date.year() distinct_years = ..... for row in distinct_years: only_year = row[year_part] On Monday, February 16, 2015 at 10:19:17 AM UTC+1, Moiz Nagpurwala wrote: > > In my controller I have this code: > > sum_of_entries = db.mydiary.id.count() > distinct_years = db(db.mydiary.id > 0).select(sum_of_entries, db.mydiary. > Entry_Date.year(), groupby=db.mydiary.Entry_Date.year(), orderby=~ > sum_of_entries) > > In my view I'm trying to display the results in a loop like so: > <ul class="list-group"> > {{for y in distinct_years:}} > {{yr=y}} #cant extract the year part into yr variable > {{count=y[sum_of_entries]}} #this extracts the count in a variable > successfully > <li class="list-group-item">{{=A(yr, _href=URL("year",args=yr))}}<span > class="badge pull-right">{{=count}}</span></li> > {{pass}} > </ul> > > when I print the "y" it outputs this result: > <Row {'_extra': {'COUNT(mydiary.id)': 1L, 'EXTRACT(year FROM > mydiary.Entry_Date)': 2001L}}> > > Please guide me to extract the year part from this Row object. > Thanks. > -- 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.