Here's what I would try:

Field('difference', compute=lambda u: (u['DT_FECHAMENTO '] - u['DT_ABERTURA ']), label='Difference')

This is untested. I haven't used compute fields based on a math function before, but like I said, this is what I'd try first.

Hope this helps.

    -Jim

On 12/21/2011 1:43 PM, Jose Carlos Junior wrote:
People,


       How can I make the field NR_INDISPONIBILIDADE the table below
(chamado) in a computed field with the difference between the field
dates DT_FECHAMENTO and DT_ABERTURA.
     Thank you,

db.define_table("chamados"
     ,Field('ID_CHAMADOS',type='id',readable=False)
     ,Field('ID_TECNICOS',type='integer',notnull=True,label='Técnico')
     ,Field('ID_CIRCUITOS',type='integer',notnull=True,label='Circuito')
     ,Field('NR_CHAMADO',type='string',notnull=False,label='Chamado')
     ,Field('DT_ABERTURA',type='datetime',notnull=True,label='Abertura')
     ,Field('DT_FECHAMENTO',type='datetime',notnull=False,label='Fechamento')
     
,Field('NR_INDISPONIBILIDADE',type='double',notnull=False,label='Indisponibilidade')
     ,Field('FL_OFENSOR',type='boolean',label='Ofensor',default=True)
     ,migrate=False
)

Reply via email to