I am using the ROracle package to pull data for a project, and before doing the pull the code syncs the R session and Oracle timezones to UTC:
Sys.setenv(TZ = "00:00")
Sys.setenv(ORA_SDTZ = "00:00")
However, based on what I've seen, our Oracle database appears to be set to Pacific time (our local timezone). So based on this I've tried changing the above code to instead sync to Pacific time.
Sys.setenv(TZ = "America/Los_Angeles")
Sys.setenv(ORA_SDTZ = "America/Los_Angeles")
I tried my original UTC pull using dates of 2018-01-01 to 2020-12-31 and my Pacific pull for that same date range and they both seem to work fine. However when I try changing the dates to 1999-01-01 to 2001-12-31 it works fine if the timezone is set to UTC but once I change it to Pacific timezone I get this error:
Error in .oci.GetQuery(conn, statement, data = data, prefetch = prefetch, :
Error in try({ :
ORA-01878: specified field not found in datetime or interval
I tried testing out my query and for some peculiar reason removing a particular variable called ATIME from the SELECT statement allows the code to work even when the timezone is set to Pacific. Does anyone have any insights into this? Could it be due to the datatype of this ATIME variable? My SQL developer program seems to indicate that the variable has a datatype of DATE. Could it perhaps be due to daylights saving time being a thing with the Pacific timezone but not with the UTC timezone? Surely if daylight saving was the issue the Pacific time code would not work with the 2018-2020 pull, but it does appear to work?