title: Comparing SQL Server DATETIME with DateTime.NOW in C# / ASP.NET
body: <p>How do I compare a SQL Server <code>DATETIME</code> with the <code>DateTime.Now</code> value? As you can see I assigned it to a Session and tried comparing it with <code>DateTime.Now</code>.</p>
  
  <pre><code>string timestamp = @"SELECT sr.*, ud.* FROM SuspensionRecord sr, UserData ud WHERE sr.User_ID=@User_ID AND ud.User_ID=@User_ID";
  
  using (SqlCommand cmd2 = new SqlCommand(timestamp, con))
  {
      cmd2.Parameters.AddWithValue("@User_ID", Session["UserID"].ToString());
  
      using (SqlDataReader dr = cmd2.ExecuteReader())
      {
          if (dr.HasRows)
          {
              while (dr.Read())
              {
                  Session["suspensiondate"] = dr["End_Date_Suspension"].ToString();
              }
  
              if (Convert.ToDateTime(Session["supensiondate"]) &gt;= DateTime.Now.Date)
              {
                  lblMessage.Text = "The account's status is suspended.";
                  lblMessage.Visible = true;
              }
          }        
      }
  }
  </code></pre>