I just tested it, and it works for me.
- add power table
- add data (NOMBRE is string column, Prox. Mant. is string column)
- add configureCell Script
now = system.date.now()
exp = system.date.parse(self.data.getValueAt(rowIndex, 'Prox. Mant.'), 'dd/MMM/yyyy')
# if current date is greater than the expiration
if now >= exp:
return {'background': 'red'}
# if the current date is within 5 months of expiration
elif system.date.monthsBetween(now, exp) <= 5:
return {'background': 'yellow'}
else:
return {'background': 'green'}
If Prox. Mant.
is already a date type column and not a string, then you don’t need system.date.parse
just the getValueAt
part
now = system.date.now()
exp = self.data.getValueAt(rowIndex, 'Prox. Mant.')
# if current date is greater than the expiration
if now >= exp:
return {'background': 'red'}
# if the current date is within 5 months of expiration
elif system.date.monthsBetween(now, exp) <= 5:
return {'background': 'yellow'}
else:
return {'background': 'green'}