Skip to content
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

odbc_result::as_double(date) should use UTC timezone #295

Merged
merged 4 commits into from Oct 8, 2019

Conversation

shrektan
Copy link
Collaborator

Closes #293

It's because the user timezone info on date is meaningless. Converting to the user timezone then extracting the date part will leading to one-day leap if the timezone is UTC+n, like Asia/Shanghai, or "Europe/Berlin".

This PR will address this issue.

Example

(Before this PR, the result is "2018-12-31")

con <- DBI::dbConnect(
  odbc::odbc(),
  server = '#hide#', database = '#hide#', uid = '#hide#', pwd = '#hide#',
  encoding = 'GB2312', driver = '{SQL Server Native Client 11.0}', port = 1433,
  timezone = 'Asia/Shanghai'
)
out <- DBI::dbGetQuery(con, "select cast('2019-01-01' as date) as aaa")
str(out)
#> 'data.frame':    1 obs. of  1 variable:
#>  $ aaa: Date, format: "2019-01-01"

Created on 2019-08-26 by the reprex package (v0.2.1)

@jimhester
Copy link
Contributor

Can you please add a bullet to NEWS? It should briefly describe the change and end with (@yourname, #issuenumber), then I can merge this.

@shrektan
Copy link
Collaborator Author

shrektan commented Oct 8, 2019

I've added one item to NEWS. Thanks.

@jimhester jimhester merged commit 4ed9ee8 into r-dbi:master Oct 8, 2019
@jimhester
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dbGet/SendQuery: Dates shifted to day before
2 participants