Perhaps you could add the seconds as a virtual lazy field.
On Wednesday, March 21, 2012 11:25:41 PM UTC-7, backseat wrote: > > On Mon, 19 Mar 2012 14:45:51 -0700 (PDT), niph...@gmail.com said: > > > for every "period", duration is calculated as: > > duration = db.periods.end_time.seconds() - > > db.periods.start_time.seconds() > > > > now, get a list of all "durations"... > > > > result = db(db.periods.id>0).select(db.periods.id, duration) > > This does not work: every 'duration' is None: > > >>> duration = db.t_periods.f_period_end.seconds() - > db.t_periods.f_period_start.seconds() > >>> result = db(db.t_periods.id>0).select(db.t_periods.id, duration) > >>> result[0] > <Row {'t_periods': <Row {'update_record': <function <lambda> at > 0x923479c>, 't_periods_archive': <gluon.dal.Set object at 0x923924c>, > 0x923479c>'id': 40, 'delete_record': <function <lambda> at 0x9234764>}>, > 0x923479c>'_extra': <Row > 0x923479c>{"(web2py_extract('second',t_periods.f_period_end) - > 0x923479c>web2py_extract('second',t_periods.f_period_start))": None}>}> > >>> > > All rows give the same result (None). > > I can see that what I need to be doing is calculating the end time in > seconds and subtracting the start time in seconds, but I can't see how to > do that via the DAL. > > Back to my original question: is the only way to do this to use > hand-crafted SQL? > -- > "You can have everything in life you want if you help enough other people > get what they want" - Zig Ziglar. > > Who did you help today? > >