ODBC -SQLQUERY和日期格式

发布于 2025-02-06 12:53:44 字数 893 浏览 1 评论 0原文

我正在尝试使用RODBC从MySQL数据库中检索数据 命令ODBCCONNECT和SQLQUERY。在 数据库,在某些情况下它可以毫无困难。不过我 其中一些错误,似乎与日期格式有关。由于我对MySQL不熟悉,我希望在这里得到一些想法。

我的代码看起来如下:

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

非常感谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文