Klipfolio Tips: Generating Weekly Date Sequences

It’s often useful in Klipfolio to create a sequence of dates for graphs or tables, spanning back in time from today to X years ago.

Use the following code to generate such sequences:

On line 5, the “1” represents YEAR. Only line 8, the “4” represents WEEK. In the Klipfolio interface these are displayed as proper values.

Change the date format string on line 10 to be whatever you need.

Ed Brocklebank is the founder of Metric Mogul, a digital analytics consultancy. He helps business of all sizes become more data-driven through marketing technology. He runs training for General Assembly London on Google Analytics and Google Tag Manager.