Awesome, works as expected.

Only change is that the request variables were strings and had to be
converted into respective data types. Thanks a lot.

On Feb 5, 4:19 pm, hywang <[email protected]> wrote:
> something like this
> def _compute():
>      return request.vars.in_time + request.vars.duration##
>
> db.define_table('mytable', Field('in_time','datetime'),
> Field('duration', 'integer'), Field('end_time','datetime', compute =
> _compute))
>
> On Feb 5, 6:51 pm, Adi <[email protected]> wrote:
>
>
>
> > Hi,
>
> > I have a table with 3 fields:
>
> > db.define_table('mytable', Field('in_time','datetime'),
> > Field('duration', 'integer'), Field('end_time','datetime'))
>
> > The user enters in_time and duration (in hours) in SQLFORM, but now I
> > want to calculate and store end_time using
> > end_time = in_time + timeinterval(hours = duration).
>
> > I'm not able to achieve this. How do I refer to a record's other
> > fields to specify default value of a field?
>
> > Thanks.

-- 
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.

Reply via email to