title: T-SQL Conversion failed when converting date and/or time from character string only on View
body: <p>I'm trying to use a T-SQL query to get data from the past week. I have view which returns the following columns:</p>
  
  <pre><code>Name (varchar) 
  Date Registered (DateTime) 
  </code></pre>
  
  <p>I am trying to use the view to only get the last weeks data. However, I keep getting the error:</p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from character string.</p>
  </blockquote>
  
  <p>Here's my sql:</p>
  
  <pre><code>DECLARE @Now DATETIME = GETDATE();
  DECLARE @6DaysAgo DATETIME = DATEADD(day,-6,@Now);
  
  SELECT * 
  FROM vw_Logs l
  WHERE convert(DATETIME, 'l.Date Registered', 121) BETWEEN @6DaysAgo and @Now
  </code></pre>
  
  <p>When I write the exact same SQL statement, using the table instead of the view, I do not get an error.</p>
  
  <pre><code>DECLARE @Now DATETIME = GETDATE();
  DECLARE @6DaysAgo DATETIME = DATEADD(day,-6,@Now);
  
  SELECT * 
  FROM tbl_Logs l
  WHERE convert(DATETIME, l.DateRegistered, 121) BETWEEN @6DaysAgo and @Now
  </code></pre>
  
  <p>I suspect it has something to do with the column names? The view has a space (<code>Date Registered</code>) and the table does not (<code>DateRegistered</code>).</p>
  
  <p>Is this the case? If so, how can I get the last weeks data from the view w/o changing the column name?</p>