title: Why is the PATINDEX returning wrong results?
body: <p>I am trying to extract the date from a string. I am using the below mentioned query using both SUBSTRING and PATINDEX:</p>
  <pre><code>SELECT Message, SUBSTRING(Message, PATINDEX('%[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]%', Message), 10) as Month_Captured
  </code></pre>
  <p>I am confused by the results &quot;CONTROL V&quot;, please see the attached image. Can you please explain why this is happening and what is the best way to extract the date from a string.</p>
  <p><a href="https://i.stack.imgur.com/AphXR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AphXR.png" alt="SQL QUERY RESULTS" /></a></p>