Change colour of a formula box if it’s a year later

?

I have a Last Updated date box and a formula box called Last updated status, I basically want to make it so after a year from the date in the last updated box the formula for the status turns red.

TIA

Ninox Profile

Try this in the formula box called Last updated status:

 

let t := days('Last Updated', today());
styled("Status", if t > 365 then "red" end)

?

It shows up as status in the box, but it doesn't change colour when more than 365 days

?

Nevermind it's sorted! Nice one Nick :)

?

Als what would I add to it to make it green when it is under 365 days? I've just tried with the same sort of code but it's not working for me.

TIA

Ninox Profile

Sure,

---

let t := days('Last Updated', today());
if t > 365 then
styled("Expired", "red")
else
if t < 365 then
styled("Not Expired", "green")
end
end

---

Change the words "Expired" and "Not Expired" to suit your needs

J

Hi Nick

 

I hope you don't mind but I would just have

 

let t := days('Last Updated', today());
if t > 365 then
styled("Expired", "red")
else
styled("Not Expired", "green")
end

 

Regards John

?

Thank you both :)

Ninox Profile

You're right John, I just wanted to show him the case of multiple ifs...

M

John/Nick

Both methods work and that is good what you have shown yewani is that there are several ways to achieve the required result - even better !!
In fact, a somewhat wise tutor once told me that when starting out with coding that was better to code it as you are saying it and have the multiple if's etc as it makes it initially easier to follow in your head. Once comfortable with what you are doing then you can go back and refine the code. I think he referred to it as spaghetti code back then cos we often resorted to jumping all over the place! Certainly made for some long coded scripts! before we embarked on proper sub routines etc. :-)

 

 

 

1 2
Reply