# Changing the foreground of a powertable row based on the result of an expression using datetime

**URL:** <https://forum.inductiveautomation.com/t/changing-the-foreground-of-a-powertable-row-based-on-the-result-of-an-expression-using-datetime/57337>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [March 17, 2022, 11:05pm UTC](https://forum.inductiveautomation.com/t/changing-the-foreground-of-a-powertable-row-based-on-the-result-of-an-expression-using-datetime/57337 "2022-03-17T23:05:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SOPerator](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@SOPerator](https://forum.inductiveautomation.com/u/SOPerator)\
**Post date:** [March 17, 2022, 11:05pm UTC](https://forum.inductiveautomation.com/t/changing-the-foreground-of-a-powertable-row-based-on-the-result-of-an-expression-using-datetime/57337/1 "2022-03-17T23:05:13Z")

</div>

I have a power table where I’d like to customize the foreground text color depending on the results of certain columns for that row, e.g. If Datetime Column A and Datetime Column B have a difference of more than 2 days, than the text will be red, otherwise it will be black. I am currently writing the script in the configureCell section of Component Scripting for the power table

I am not sure how exactly to go about grabbing these variables for all rows, and I’m not sure if I will be able to import the datetime library, since it seems I’m only able to edit the configureCell function, and as far as I know libraries should be imported at the very top of the script. Any help would be appreciated. Thank you

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 17, 2022, 11:09pm UTC](https://forum.inductiveautomation.com/t/changing-the-foreground-of-a-powertable-row-based-on-the-result-of-an-expression-using-datetime/57337/2 "2022-03-17T23:09:18Z")

</div>

I think you should be able to use [system.date.daysBetween()](https://docs.inductiveautomation.com/display/DOC79/system.date.*Between).

EDIT: More likey, use hours or minutes between, as the result is an integer. 😉

---

<div class="post-metadata">

**Author:** ![SOPerator](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@SOPerator](https://forum.inductiveautomation.com/u/SOPerator)\
**Post date:** [March 17, 2022, 11:22pm UTC](https://forum.inductiveautomation.com/t/changing-the-foreground-of-a-powertable-row-based-on-the-result-of-an-expression-using-datetime/57337/4 "2022-03-17T23:22:53Z")

</div>

Thanks, I didn’t know about that! To access the columns for each row, what would that look like? I’m not exactly sure how to access the colIndex values per row.  
Will I need a for loop from range(0,Count) of the table, or is there an easier way to apply it to all rows?
