ODBC - sqlQuery and date format

141 views Asked by At

I am trying to retrieve data from a MySQL Database using RODBC with the commands odbcConnect and sqlQuery. There are different tables in the database and in some cases it works without any difficulties. Nevertheless I get an error with some of them and it seems to be related to date format. Since I'm not familiar with MySQL I hope to get some ideas here.

My code looks as follows:

library(RODBC)
mycon<-odbcConnect("nicer_64")
> data1<-sqlQuery(mycon,paste("select PID, NAME, FIRSTNAME1, SEXE from a_patient;"))
> head(data1)
    PID     NAME       FIRSTNAME1 SEXE
1 22145 PILLONEL   GASTON ANTONIN    1
2 22146  PORCHER  HENRIETTE MARIE    2
3 22147    PUGIN   AUGUSTE JOSEPH    1
4 21437     HEIZ MARIE ANTOINETTE    2
5 21439     KALT             OTTO    1
6  2144  BRUNNER            MARIE    2
> data2<-sqlQuery(mycon,paste("select PID, NAME, FIRSTNAME1, BIRTHDATE, SEXE from a_patient;"))
Error in as.POSIXlt.character(x, tz, ...) : 
  la chaîne de caractères n'est pas dans un format standard non ambigu
> head(data2)
Error in head(data2) : object 'data2' not found

Many thanks in advance!

0

There are 0 answers