Error as.POSIXlt.Character when importing MDB into R

Asked

Viewed 370 times

6

Hi, I looked all over the internet for that answer and I didn’t find :)

I am importing an MDB (Ms Access db) into R Studio (Windows 7 R v32b) using RODBC but when giving the sqlFetch command I am having an error in importing a date column that is in dd/mm/YYYY (Brazilian date format).

This is the code I’m running:

install.packages('RODBC',repos='http://cran.r-project.org')
library(RODBC)
channel <- odbcConnectAccess("db.mdb")
JE <- sqlFetch(channel, sqtable="Table", colnames = FALSE, rownames = FALSE)

And that’s the result:

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format

I tried to debug sqlFetch but cannot identify where this error is occurring. Does anyone know how to edit this function to fix this failure?

Thank you!

  • William, maybe you can upload a sample of the *.mdb file, this would help to reproduce the error and maybe give an alternative as a solution.

  • 2

    tries to use the argument as.is = T. JE <- sqlFetch(channel, sqtable="Table", colnames = FALSE, rownames = FALSE, as.is = T)

  • That’s it! It worked!

  • @Danielfalbel, please post the comment with the solution as an answer.

  • @Guilhermelouzed if Daniel doesn’t post the solution yourself as an answer and close the question. It may be useful for other users.

  • @Flaviobarros already put!

Show 1 more comment

1 answer

4


Try to use the argument as.is = T.

JE <- sqlFetch(channel, sqtable="Table", colnames = FALSE, rownames = FALSE, as.is = T)

Then you can convert to date using as.Date.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.