title: C# If statement where date is this month
body: <pre><code>string month = DateTime.Now.Month.ToString();
  string CommandText = "SELECT slocref.slocname, partstuff.quantity, partstuff.currency, partstuff.postingdate" + " FROM partstuff INNER JOIN slocref ON partstuff.sloc = slocref.slocvalue";
  </code></pre>
  
  <p>This is the code to get date and month.</p>
  
  <pre><code>if (Regex.IsMatch(rdr["postingdate"].ToString(), "0" + month + "*"))
  {
      if (rdr["slocname"].ToString() == "Answer/Slatwall")
      {
          string quantity = rdr["quantity"].ToString();
          string currency = rdr["currency"].ToString();
          answertotalmonth += float.Parse(currency);
          label100.Text = "$" + answertotalmonth.ToString("#,##0.00");
      }
  }
  </code></pre>
  
  <p>This is just an example of the code that is run by the if statement. </p>
  
  <p>But the if statement needs to get all of the July information and add it up. So from 07/01/2012 to 07/31/2012. I cannot change the SQL because it messes up the rest of the program. I tried to get the current date, add the 0 in front of it, then use a wildcard.</p>
  
  <p>Need a little direction on this if statement.</p>
  
  <p>Let me clarify this post. The "postingdate" value comes from FileHelpers. Importing a text file by fixed width into these values. The postingdate value looks like "07/16/12"</p>
  
  <p>So, I want to get this current month, and then if a postingdate value has that month's value, run the if statement code. </p>