0

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

10replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Nick
    • Nick
    • 8 mths ago
    • Reported - view

    Try this in the formula box called Last updated status:

     

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

    Like
    • yewani
    • yewani
    • 8 mths ago
    • Reported - view

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

    Like
    • yewani
    • yewani
    • 8 mths ago
    • Reported - view

    Nevermind it's sorted! Nice one Nick :)

    Like
    • yewani
    • yewani
    • 8 mths ago
    • Reported - view

    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

    Like
    • Nick
    • Nick
    • 8 mths ago
    • Reported - view

    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

    Like
    • John Halls
    • John_Halls
    • 8 mths ago
    • Reported - view

    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

    Like
    • yewani
    • yewani
    • 8 mths ago
    • Reported - view

    Thank you both :)

    Like
    • Nick
    • Nick
    • 8 mths ago
    • Reported - view

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

    Like
  • 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. :-)

    Like
  • That's beautifully put, as ever Mel 👍

    Like
Like Follow
  • 8 mths agoLast active
  • 10Replies
  • 463Views