Closed GoogleCodeExporter closed 9 years ago
Hi Sandor
It so happens that Tomoaki just committed changes to SVN for datetime with
timezone parsing. Could you try the SVN version, please?
Also, could you provide us with a full "quoted" example to see what your German
date strings look like, and if/how psql parses them correctly.
I only ever work in a (default US) English locale so I would not know if we
need to tweak this at the R side, the PostgreSQL side or both. But without a
reproducible example we have nothing to go by.
Dirk
Original comment by dirk.eddelbuettel
on 14 Oct 2012 at 4:06
Dear Dirk,
thank you for answering ever so quickly. I think I solved the problem. But
first your request:
The query
> dbSendQuery(con,"select anytimefield::varchar from anytable")
returns:
> fetch(rs,2)
anytimefield
1 14.10.2012 14:01:05.645
2 14.10.2012 14:01:05.661
As it seems, R cannot translate it to a Date/Time field. If, however, I prepend
the assignment
> dbSendQuery(con,"SET datestyle TO iso")
everything works fine!
So in summary, one has to tell PostgreSQL to return date/time fields in a
format readable by R.
Greetings and thank you again,
Sandor
Original comment by Sandor...@googlemail.com
on 15 Oct 2012 at 9:30
You are at right position that
dbSendQuery(con,"SET datestyle TO iso")
solves the problem.
However the default is the ISO format according to the postgresql manual.
http://www.postgresql.org/docs/9.2/static/datatype-datetime.html#DATATYPE-DATETI
ME-OUTPUT
> So in summary, one has to tell PostgreSQL to return date/time fields in a
format readable by R.
So, this should read one has to tell PostgreSQL to use standard format for the
communication if the server is intentionally set to return other local format.
You wrote specifically:
1. PostgreSQL Server 9.1 on Windows Server 2003 R2, datestyle = 'German'
DMY and MDY is not distiguishable from the data by itself. Thus, I do strongly
recommend sticking to ISO format.
The manual says:
The date/time style can be selected by the user using the SET datestyle
command, the DateStyle parameter in the postgresql.conf configuration file, or
the PGDATESTYLE environment variable on the server or client.
So, from the client side, the PGDATESTYLE may affect the behavior, but the
LC_TIME is unlikely to affect.
Original comment by tomoa...@kenroku.kanazawa-u.ac.jp
on 17 Oct 2012 at 1:20
As of r242,
dbSendQuery(con,"SET datestyle TO iso")
is issued at the connection unless otherwise specified.
(Default is to force to ISO conversion. As this does affect query like
date_field::text, this can be suppressed with an option.)
Original comment by tomoa...@kenroku.kanazawa-u.ac.jp
on 22 Oct 2012 at 7:23
Original issue reported on code.google.com by
Sandor...@googlemail.com
on 14 Oct 2012 at 3:01