title: Convert mm/dd/yyyy hh:mm;ss AM/PM to datetime
body: <p>When I am trying to convert date I am getting below error</p>
  
  <pre><code>DECLARE @MinLogDate AS varchar(100)
  DECLARE @MinDate AS DATETIME
  
  SET @MinLogDate = '10/26/2012 01:23:90 AM'
  SET @MinDate = (SELECT CONVERT(CHAR(10), CONVERT(datetime, @MinLogDate,103),101))
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p><em>The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.</em></p>
  </blockquote>
  
  <p>How can I convert the varchar time to datetime?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>based on the answer i have modified.. below is the actual date time i am getting .. so now I am able to get mindate but max date is not working</p>
  
  <pre><code>    DECLARE @MinDate AS DATETIME
      DECLARE @MaxDate AS DATETIME
      DECLARE @MinLogDate AS varchar(100)
      DECLARE @MaxLogDate AS varchar(100)
  
      SET @MinLogDate = '8/1/2012 01:00:00 AM'
      SET @MaxLogDate = '8/31/2012 01:00:00 PM'
  
      SET @MinDate = CONVERT(datetime, LEFT(@MinLogDate, 10), 101)
      SET @MaxDate = CONVERT(datetime, LEFT(@MaxLogDate, 10), 101)
  
      SELECT @MinDate
      SELECT @MaxDate
  </code></pre>