title: SQL Issue using SUBSTRING and LEN
body: <pre><code>SELECT [Code], [Due Date Calculation],
  
  --original string that is causing the error
  --SUBSTRING([Due Date Calculation], 1, LEN([Due Date Calculation]) - 1) as OG,
  
  --here are the tests that run fine by themselves
  LEN([Due Date Calculation]) - 1 as Test1,
  SUBSTRING([Due Date Calculation], 1, 2) AS Test2, 
  SUBSTRING([Due Date Calculation], 1, LEN([Due Date Calculation])) AS Test3 
  
  FROM [TEST]
  </code></pre>
  
  <p>Here is the error I am getting: </p>
  
  <blockquote>
    <p><strong><em>Msg 537, Level 16, State 2, Line 1
    Invalid length parameter passed to the LEFT or SUBSTRING function.</em></strong></p>
  </blockquote>
  
  <p>I know it has something to do with the way SQL is rendering the data. The data displays a small upside down 'L' when I query it using SQL, but it simply shows a 'D' in the front end. I don't have a good enough reputation to include the images. An example of a typical Codes are <code>30D</code>, <code>60D</code>, <code>120D</code>, <code>365D</code>, etc.</p>
  
  <p>I need to drop the trailing D and display what is left.</p>
  
  <p>Thanks for the help.</p>
  
  <p>Here are the results from the SQL Query:
  [<a href="https://drive.google.com/file/d/0B1cL-bzbZ4IzU2ctYlRNZnJhZjg/view?usp=sharing][1]" rel="nofollow">https://drive.google.com/file/d/0B1cL-bzbZ4IzU2ctYlRNZnJhZjg/view?usp=sharing][1]</a></p>