Change date color

So..I have column "Date Published" and I want dates in this column to become red when they are min 2 years old.
I found a solution that I suppose would help but I'm missing the part older than 2 years. I'm a total newbie so any help is appreciated.

    @if (data.Quantity > 20)
    {
       <span style='color:white'>@data.Quantity</span>
    }
    else
    {
       <span style='color:black'>@data.Quantity</span>
    }

Hi @ico00,

Something like this should help:

@if (DateTime.Now.Subtract(data.DatePublished).Days >= 2 * 365)
    {
       <span style='color:white'>@data.DatePublished</span>
    }
    else
    {
       <span style='color:black'>@data.DatePublished</span>
    }

It uses the Subtract method of the DateTime class and checks if the Days of the returned TimeSpan are >= than 2 * 365 (about two years).

That did the trick. Thanks.