You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue where start and end dates are off by 1 day.
The following is a toy example, but I am able to reproduce the error on my machine using this. (The query I want to run is for the full month, which is why I'm using split_daywise = T, delay = 5 )
load("token_file") # in the actual code I use a full local path to the token file
ValidateToken(token)
query.list <- Init(start.date = "2016-05-01",
end.date = "2016-05-02",
dimensions = "ga:date,ga:source,ga:medium,ga:deviceCategory",
metrics = "ga:sessions",
max.results = 10000,
table.id = "ga:xxxxxxxxxx"
)
ga.query <- QueryBuilder(query.list)
ga.data <- GetReportData(ga.query, token, split_daywise = T, delay = 5)
This will return:
Access Token is valid.
[ Run 0 of 1] Getting data for 2016-04-30
[ Run 1 of 1] Getting data for 2016-05-01
The API returned 460 results.
Anyone else experiencing this or have an idea what could be causing it?
The only date arithmetic I've found in the execution of the above is in SplitQueryDaywise() in line 43 where date <- format(as.POSIXct(start.date) + days(i), '%Y-%m-%d') but it's addition, and my issue is that 1 day is being subtracted.
If I execute that code directly in the console, the calculation is performed correctly, returning "2016-05-01" for i = 0 and start.date = "2016-05-01"
When I set a breakpoint at line 41 in SplitQueryDaywise() and step through the calculation, everything looks fine. I hit next and i is set to 0. I hit next again, and date <- format(as.POSIXct(start.date) + days(i), '%Y-%m-%d') evaluates to "2016-04-30"
Also, if I drop the split_daywise and delay arguments, the ga:date data shows that the data is correctly from 5/1 and 5/2. Unfortunately if I try to get the whole month, it introduces sampling, which I want to avoid. But if I split daywise, the dates are off.
System info in case it's relevant:
Windows 7 32 bit
R version 3.3.0
Rstudio 0.99.893
RGoogleAnalytics 0.1.5
lubridate 1.5.6
httr 1.1.0
digest 0.6.9
The text was updated successfully, but these errors were encountered:
I've been able to work around it by replacing as.POSIXct(start.date) in line 43 of SplitQueryDaywise.R with either as.Date(start.date) or as.POSIXlt(start.date). With both alternatives, the date artithmetic works for me then.
However, I still don't understand why the error only appeared during execution of SplitQueryDaywise() but executing the same code directly in the console produced no error:
start.date <- "2016-05-01"
i <- 0
date <- format(as.POSIXct(start.date) + days(i), '%Y-%m-%d')
date
[1] "2016-05-01"
I also don't know what the implications are of using as.POSIXlt or as.Date are since all three work with time differently. If anyone knows of issues that could arise from using one of these other functions, I'd love to know.
I'm having an issue where start and end dates are off by 1 day.
The following is a toy example, but I am able to reproduce the error on my machine using this. (The query I want to run is for the full month, which is why I'm using
split_daywise = T, delay = 5
)This will return:
Anyone else experiencing this or have an idea what could be causing it?
The only date arithmetic I've found in the execution of the above is in
SplitQueryDaywise()
in line 43 wheredate <- format(as.POSIXct(start.date) + days(i), '%Y-%m-%d')
but it's addition, and my issue is that 1 day is being subtracted.If I execute that code directly in the console, the calculation is performed correctly, returning "2016-05-01" for i = 0 and start.date = "2016-05-01"
When I set a breakpoint at line 41 in
SplitQueryDaywise()
and step through the calculation, everything looks fine. I hit next andi
is set to 0. I hit next again, anddate <- format(as.POSIXct(start.date) + days(i), '%Y-%m-%d')
evaluates to"2016-04-30"
Also, if I drop the split_daywise and delay arguments, the ga:date data shows that the data is correctly from 5/1 and 5/2. Unfortunately if I try to get the whole month, it introduces sampling, which I want to avoid. But if I split daywise, the dates are off.
System info in case it's relevant:
Windows 7 32 bit
R version 3.3.0
Rstudio 0.99.893
RGoogleAnalytics 0.1.5
lubridate 1.5.6
httr 1.1.0
digest 0.6.9
The text was updated successfully, but these errors were encountered: