title: Create a date from Credit Card expire in MMYY format
body: <p>I need to convert a credit card expire field from MMYY to a date field I can use in a MS SQL query so I can compute when credit cards are expiring in the future. Basically, I need to go from MMYY to MM/DD/YYYY, where the day part could just be '01' (the first of the month).</p>
  
  <p>I'm looking for credit cards that are expiring next month from a database. The problem I'm running into is when next month is the first month of the next year.</p>
  
  <p>Here's the code I have for determining expired card:</p>
  
  <pre><code>(CAST(SUBSTRING(CCExpire,3,2) as int) + 2000 &lt; YEAR(GETDATE()))
  or
  (
      (CAST(SUBSTRING(CCExpire,3,2) as int) + 2000 = YEAR(GETDATE()))
      AND
      (CAST(SUBSTRING(CCExpire,1,2) as int) &lt; MONTH(GETDATE()))
  )
  </code></pre>
  
  <p>And here's the code for cards expiring this month:</p>
  
  <pre><code>(CAST(SUBSTRING(CCExpire,3,2) as int) + 2000 = YEAR(GETDATE()))
  AND
  (CAST(SUBSTRING(CCExpire,1,2) as int) = MONTH(GETDATE()))
  </code></pre>
  
  <p>Now I need code for cards expiring next month...</p>