title: How to compare Sharepoint List Items Values?
body: <p><img src="https://i.stack.imgur.com/tX6ay.jpg" alt="enter image description here"></p>
  
  <p>Dear All,</p>
  
  <p>My list constains date/time items and I want to get the biggest value of dates. For my example, 1 May 2012 nearest day for today? how can I compare these values and get latest one with C#? I accessed the list and Items in code;</p>
  
  <pre><code>using (SPWeb web = SPContext.Current.Site.RootWeb)
  {
        SPList alertList = web.Lists["Alert Status"];
        if (alertList != null)
        {
            foreach (SPListItem alertItem in alertList.Items)
            {
                DateTime startDate = (DateTime)alertItem["Alert Date"];
  
            }
        }
  } 
  </code></pre>