title: How to Compare two date without timeline in C#
body: <p>I want to compare two dates. In pseudo-code:</p>
  
  <pre><code>If the dueDate &gt; now or dueDate = now 
  
  Then Fine Amount = something.
  
  Else Fine Amount = 0
  </code></pre>
  
  <p>I wrote below code:</p>
  
  <pre><code>DateTime dueDate = Convert.ToDateTime(Reader1[3].ToString());
  DateTime now = DateTime.Now;
  int result = DateTime.Compare(dueDate, now);
  if ((result &lt; 0) || (result == 1))
  {
      row["Fine_Amount"] = Convert.ToDouble(Reader1[4].ToString()); 
  }
  else
  {
      row["Fine_Amount"] = 0;
  }
  </code></pre>
  
  <p>This code gives wrong value, when</p>
  
  <pre><code>dueDate = 23-12-2011 AM 12:00:00
  now = 23-12-2011 PM 05:26:54
  </code></pre>
  
  <p>I want to Compare:</p>
  
  <pre><code>dueDate = 23-12-2011
  now = 23-12-2011
  </code></pre>
  
  <p>How do I remove the time in that?.</p>
  
  <p>Adding below code is given result. But its to lengthy code.: -</p>
  
  <pre><code> DateTime dueDate = Convert.ToDateTime(Reader1[3].ToString());
                      DateTime now = DateTime.Now;
  
                      if (dueDate.Year &lt; now.Year)
                      {
                          row["Fine_Amount"] = Convert.ToDouble(Reader1[4].ToString());
                      }
                      else if (dueDate.Year &gt; now.Year)
                      {
                          row["Fine_Amount"] = 0;
                      }
                      else if (dueDate.Year == now.Year)
                      {
                          if (dueDate.Month &lt; now.Month)
                          {
                               row["Fine_Amount"] = Convert.ToDouble(Reader1[4].ToString();
                          }
                          else if(dueDate.Month &gt; now.Month)
                          {
                               row["Fine_Amount"] = 0;
                          }
                          else if(dueDate.Month == now.Month)
                          {
                               if(dueDate.Day &lt; now.Day)
                               {
                                   row["Fine_Amount"] = Convert.ToDouble(Reader1[4].ToString();
                               }
                               else
                               {
                                   row["Fine_Amount"] = 0;
                               }
                          }
                      }
  </code></pre>
  
  <p>Is there any way to short this code?.</p>
  
  <p>Answer For this Question is</p>
  
  <pre><code>if (dueDate.Date &gt;= now.Date)
  {
      row["Fine_Amount"] = 0;
  }
  else
  {
      row["Fine_Amount"] = Convert.ToDouble(Reader1[4].ToString());
  }
  </code></pre>
  
  <p>This datetime.date is gives</p>
  
  <pre><code> dueDate = 23-12-2011 AM 12:00:00 to 23-12-2011 AM 12:00:00 
      now = 23-12-2011 PM 05:26:54 to 23-12-2011 AM 12:00:00 
  </code></pre>