-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postgres returning bad dates, related to datestyle? #287
Comments
Another head-scratcher:
today is 2020-01-20, aka 20-01-2020 (DMY), aka 01-20-2020 (MDY) |
@krlmlr you were right about datestyle it seems: Not sure why I didn't try this earlier.
If I explicitly set the datestyle then all subsequent results have properly formatted dates and times. |
Thanks. So the workaround seems obvious: issue a The question remains why libpq relies on this configuration, and how to retrieve values via libpq that work regardless of this configuration. It might be impossible, then the workaround is all that remains. Would you like to contribute a pull request? |
sure, can do. |
- `dbConnect()` now issues `SET datestyle to iso, mdy` to avoid translation errors for datetime values with databases configured differently (#287, @baderstine).
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary. |
Postgres returning dates/timestamps as very different from database values using R (3.6.3).
Within pgAdmin 4.x the source column value is:
2018-07-27 09:19:43 (column type is "timestamp without time zone")
Using RPostgres 1.2.0 returns 2719-03-09 05:40:03
Using RPostgres 1.3.1 returns 2719-04-22 05:40:03
Also get really strange results from my db when running test-timezone.R, which really seems like a date formatting issue:
I noticed the same issue with
date
formatted columns.source : output
"2010-04-10" : "1015-01-05",
"2009-12-30" : "3005-09-10"
In PgAdmin, I ran
show datestyle
and it returned "ISO, DMY".On a different PostgreSQL database that I connect to using RPostgres (without SSL, not sure if that's relevant),
show datestyle
returns "ISO, MDY" and queries of this database return perfectly normal results for all of the above queries (timestamps, etc. are correct).It seems that the first two characters of the returned date value are always the "day" of the original date, but cannot sort out how the other date characters are determined.
The text was updated successfully, but these errors were encountered: