asp.net C# DateTime Condition -


i have listview fetches data sql database. 1 of columns date takes data database in format "mm/dd/yyyy 0:00:00 am"

i'm trying date highlight if on hour old datetime.now

here have (yes know it's wrong)

label timelabel = (label)e.item.findcontrol("tptimein");             if (timelabel != null)             {                 datetime total;                 if (datetime.tryparse(timelabel.text, out total) == true)                 {                     if (total < (datetime.now))                     {                         timelabel.backcolor = system.drawing.color.red;                         timelabel.forecolor=system.drawing.color.white;                     }                 }             } 

any appreciated, i'm quite new coding go easy on me!

use datetime.addhours(1). see msdn

if(total > datetime.now.addhours(1))  {      timelabel.backcolor = system.drawing.color.red;      timelabel.forecolor=system.drawing.color.white; } 

Comments