title: How to check date between 2 dates (not SQL)
body: <p>In my WinForm, user input in textbox date as '210514' or '231113 (in ddmmyy format)
  Assume today date = 291014 (29-Oct-14).
  Using Visual Studio 2010 C# 4.0.
  PC date time setting: GMT +08:00 dd-MMM-yy.</p>
  
  <p>CodeBehind:</p>
  
  <pre><code>// Split the input string into YYMMDD format and set it to a date object
  DateTime inputDate = new DateTime(Convert.ToInt32(input.Substring(4, 2)), Convert.ToInt32(input.Substring(2, 2)), Convert.ToInt32(input.Substring(0, 2)));
  </code></pre>
  
  <p>// the WinForm allows user to input date not earlier than 2 years before today date and not more than 1 months from today date too. </p>
  
  <pre><code>DateTime minDate = DateTime.Now.AddMonths(-24);
  DateTime maxDate = DateTime.Now.AddMonths(1);
  </code></pre>
  
  <p>I tried many methods but none works (I have checked many threads/forums also).</p>
  
  <pre><code>//Method 1
  if(inputDate &gt;= minDate &amp;&amp; inputDate &lt;= maxDate)
      return true
  
  //Method 2: B return true but A ***always*** return false, Why??
  if (inputDate &gt;= minDate)
      A = true;
  
  if (inputDate &lt;= maxDate)
      B = true;
  
  //Method 3: B return true but A ***always*** return false, Why??
  if ((DateTime.Now - inputDate).Days &gt;= (DateTime.Now - minDate).Days)
      A = true;
  
  if (inputDate &lt;= maxDate)
      B = true;
  </code></pre>