Snowflake date shifted by 1 day when importing the data into R

Viewed 140

We have a database in SNOWFLAKE. When I execute this query

SELECT REQUEST_ID, DUE_DATE FROM table WHERE REQUEST_ID = 'abc'

I get this as result.

enter image description here

I execute the same query in R

query <- "SELECT REQUEST_ID, DUE_DATE FROM table WHERE REQUEST_ID = 'abc'"
data1 <- DBI::dbGetQuery(con, query)

I get this as result.

enter image description here

As you may have noticed the dates are shifted by 1 day. The data type in snowflake is of type DATE whereas in R it is of type character. I am not sure what is causing this issue. I initially thought it might be because of timezone so I tried changing timezone in SNOWFLAKE by running the following lines

ALTER USER SET TIMEZONE = 'UTC'
ALTER SESSION SET TIMEZONE = 'UTC'

but it did not change anything. Later I read that DATES do not have time component in them so are not affected by timezones. I am not sure where to look and what to change to fix this issue. I would appreciate if you could give me any pointers.

This is how I create the connection (con) object -

con <- DBI::dbConnect(RJDBC::JDBC("net.snowflake.client.jdbc.SnowflakeDriver", driver), url)
1 Answers
Related