title: Importing Dates into R from SQL Server
body: <p>I am trying to query a SQL Server database to check for the MAX date in one field and to select the next day for input into another process. I am able to query the database and pull back a date, but I can't convert it into a date object.</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>tmpMaxDate &lt;- sqlQuery(dbhandle, 'select MAX([date]) + 1 from dbo.My_Data ')
  tmpMaxDate
  
  1 2016-01-02
  IsDate(tmpMaxDate)
  [1] FALSE
  
  maxDate    &lt;- as.Date(tmpMaxDate)
  Error in as.Date.default(tmpMaxDate) : 
    do not know how to convert 'tmpMaxDate' to class “Date”
  maxDate
  NULL
  IsDate(maxDate)
  [1] FALSE
  
  
  maxDate &lt;- as.Date(tmpMaxDate, format = "%Y-%M-%D")
  Error in as.Date.default(tmpMaxDate, format = "%Y-%M-%D") : 
    do not know how to convert 'tmpMaxDate' to class “Date”
  
  IsDate(maxDate)
  [1] FALSE
  maxDate
  NULL
  </code></pre>
  
  <p>The packages I am using are RODBC, chron, lubridate, and RSQLserver
  I thought I needed to convert to a date object to use the date from SQL Server in R. </p>
  
  <p>Any thoughts on why my date won't convert?  Do I need to convert to be able to use that date to filter data in R?</p>