Checking if a DateTime is before DateTime.Now

Newbie picture Newbie · Jul 29, 2013 · Viewed 28.3k times · Source

How can I check using some form of if statement if a certain DateTime, (say in this case called dateAndTime1) is before the current date and time, which I presume will be retrieved using DateTime.Now?

Answer

Jim picture Jim · Jul 29, 2013
if(dateAndTime1 < DateTime.Now)
{
  //do something
}