title: Best method for varchar date validation in Sybase (T-SQL)?
body: <p>I have a stored procedure which takes as its parameter a <em>varchar</em> which needs to be cast as a <em>datetime</em> for later use:</p>
  
  <pre><code>SET @the_date = CAST(@date_string AS DATETIME)
  </code></pre>
  
  <p>I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't be cast successfully, I want to default to the system date and continue. In PL/SQL I could use exception handling to achieve this and I could do this fairly easily with regular expressions too, but the limited pattern matching supported out of the box by Sybase doesn't let me do this and I can't rely on third party libraries or extensions. Is there a simple way of doing this in T-SQL?</p>
  
  <p><em>NB: using Sybase ASE 12.5.3, there is no ISDATE function</em></p>