title: T-SQL convert varchar yyyy-MM-dd-hh.mm.ss.nnnnnn into datetime
body: <p>This is in MS SQL Server.</p>
  
  <p>I have a varchar in the format yyyy-MM-dd-hh.mm.ss.nnnnnn</p>
  
  <p>For example: 2010-09-17-20.52.31.870000</p>
  
  <p>I want to convert this into a datetime... but ISDATE function in MSSQL says that is not a valid date and CONVERT won't work.  Is there a way to use the convert function so that I can tell it what format the date is in?</p>
  
  <p>I also want to check first that it is a valid date since the varchar input may contain nothing or it may contain an invalid date.  </p>
  
  <p>For example, invalid data of 2010-xx-r7-99.53esdfd.31.870000... I would skip that data and not even try to convert.</p>