如何将系统日期添加到需要字符串格式的日期的函数?

时间:2022-11-16 15:15:14

I am trying to use the RGoogleAnalytics package to automate reports on our website. Queries look like this:

我正在尝试使用RGoogleAnalytics包在我们的网站上自动生成报告。查询看起来像这样:

# Create a list of Query Parameters
query.list <- Init(start.date = "2014-11-28",
                   end.date = "2014-12-04",
                   dimensions = "ga:pageTitle",
                   metrics = "ga:sessions,ga:pageviews",
                   max.results = 1000,
                   table.id = "ga:XXXXXX")

I want to replace those dates with the Sys.Date()-1 and Sys.Date(), respectively, but the function requires that they are in string format. I've thought about writing a separate function that prints out the query.list with the Sys.Dates as a string, but I'm not certain how to go about that.

我想分别用Sys.Date() - 1和Sys.Date()替换这些日期,但该函数要求它们是字符串格式。我已经考虑过编写一个单独的函数来打印出带有Sys.Dates作为字符串的query.list,但我不确定如何去做。

1 个解决方案

#1


1  

You are looking for :

您正在寻找:

as.character(Sys.Date()-1)

#1


1  

You are looking for :

您正在寻找:

as.character(Sys.Date()-1)