title: I have a condition comparing DateTime in C# using the < operator and it return's false even if it should not. Why?
body: <p>I have this code below and the "if ((DateTime)DataReader[0] > DateTime.Now)" condition returns false even if the datetime in the database is greater than the datetimenow.</p>
  
  <p>I used this code before and it use to work I never changed any thing.</p>
  
  <p>So the question is why does the condition return false?</p>
  
  <p>Thanks,</p>
  
  <p>Simon</p>
  
  <pre><code>Boolean active = false;
  SqlConnectionUniqueInstance.Instance.Open();
  SqlCommand Command = SqlConnectionUniqueInstance.Instance.Connection.CreateCommand();
  Command.CommandText = String.Format(@"SELECT [LogoutDateTime] FROM [dbo].[sessions] WHERE [sessionID] = {0}", sessionId.ToString());
  SqlDataReader DataReader = Command.ExecuteReader();
  while (DataReader.Read())
  {
  
      if ((DateTime)DataReader[0] &gt; DateTime.Now)
          active = true;
  }
  DataReader.Close();
  if (active)
      UpdateTime(sessionId);
  Command.Dispose();
  return active;
  </code></pre>