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
Contributor

shrektan commented Aug 26, 2019

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

This comment has been minimized.

Copy link
Member

jimhester commented Oct 8, 2019

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

This comment has been minimized.

Copy link
Contributor Author

shrektan commented Oct 8, 2019

I've added one item to NEWS. Thanks.

shrektan and others added 2 commits Oct 8, 2019
@jimhester jimhester merged commit 4ed9ee8 into r-dbi:master Oct 8, 2019
1 check was pending
1 check was pending
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Oct 8, 2019

Thanks!

@shrektan shrektan deleted the shrektan:fix293 branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.