About dates and time in Data Studio

Learn the basics of working with date and time-based data.

Creating reports that visualize how your data changes over time is a core feature in any reporting or business intelligence tool. To do this in Data Studio, you'll want to know how to accomplish the following tasks:

  • Setting up the dimensions in your data source that contain date information.
  • Adding and customizing date-based charts in a report.
  • Setting the default time frame and comparison period, if desired.

Additionally:

  • You may want to give your viewers a way to adjust the report time frame.
  • Depending on your needs and your underlying data, you may want to manipulate dates in a calculated field.
In this article:

Dates in data sources

A date in your underlying data set is represented by a date dimension in your data source. The data type of that dimension should match the kind of date in your data set. For example, if your underlying date is the full calendar date, then your dimension should have the type Date (YYYYMMDD). On the other hand, if your date is incomplete, such as just quarter and year, then the dimension should have the matching type Year Quarter (QYYYY).

In order to work with dates properly, your data source must have at least one dimension of type Date (YYYYMMDD).
 
Learn more about date types.

Set up your date dimensions

In many cases, Data Studio automatically detects the date dimensions in your data and assigns the appropriate type to those fields. If this isn't the case, you can adjust the field type by editing the data source.

Manipulate dates in data sources

There are two ways to change or manipulate the date fields in a data source:

  • By changing the field's data type.

    Best practice is to duplicate the existing field, then change the type of the copy.

  • By creating a calculated field that uses the TODATE() function.

Dates in reports

Dates in your reports serve two primary purposes: controlling the date range to report on, and aggregating your data in charts according to the desired date scope or level.

Control the date range of your reports

The Date Range Dimension provides the dates you can use to how much time you want to report on. This can be any dimension in your data source that has the Date (YYYYMMDD) data type. You can set a Date Range Dimension for individual charts and controls, the current page, or the entire report.

Components based on Google Analytics have the Date Range Dimension set automatically. For other data source types, you may need to set this manually if Data Studio can't find a valid date dimension, or if your data source contains a different dimension you want to use.

Set up the Date Range Dimension
  1. Select a chart or control.
  2. Select the DATA tab.
  3. In the Data Source section, click the Date Range Dimension, then use the dimension picker to select a valid date dimension.

The Date Range Dimension can also be set at the report or page level using the File > Report settings menu or the Page > Current page settings menu.

Default date range

The default date range for your charts and controls depends on their data source. For example, charts based on Google Analytics data show the last 28 days' worth of data by default. Charts based on Google Sheets show all the data in the sheet. You can change the amount of data shown by setting the Default Date Range property. You can set this property for your entire report, specific page, or for one or more charts and controls on a page.

Set up the Default Date Range

To change the default date range for the entire report, edit that report and select the File > Report settings menu.

To change the default date range for a specific page, edit that page and select the Page > Current page settings menu.

To change the default date range for one or more charts or controls, select them.

Next:

  1. In the Properties panel on the right, select the DATA tab.
  2. Scroll down to find the Default Date Range property.
  3. Select Custom.
  4. Click the currently selected range to display the date range options.

Date range options

You can use the calendar widget to define either a fixed date range, or a rolling date windowCalendar icon.

Fixed date ranges let you set beginning and ending dates. Your chart will always show that specific time frame.

To set a rolling date window, select one of the predefined options, such as "Last week" or "Last month." Rolling date ranges are relative to "today."

Use the Include today check box to include any data collected so far for the current day (if applicable).
Data Studio defaults to starting the weekly rolling window on Sunday. You can change this to start on Monday by selecting This week (starts Monday) or Last week (starts Monday) in the date options list.

Dates in charts

Any chart in Data Studio can display date dimensions. However the time series and area chart are optimized to display date-based information, because they include a time dimension. The time dimension specifies how you want to aggregate the data according to the date unit.

For example, if you use a time dimension that has a type of Date (YYYYMMDD), your chart shows aggregated data by year, month, and day. If you choose a time dimension with a type of Year Month (YYYYMM), your data is aggregated by those units (year and month). In addition, the time series and area charts automatically sort by date, whereas other charts allow sorting by any dimension or metric.

Compare to previous period

Some charts can compare one date range to another. You can compare the current range to the previous matching period (for example, compare this week to last week), to the current date range in the previous year, or to a custom period of your choosing.

Examples of date comparisons

How to compare to previous periods

  1. Select a time series, table, area chart, or scorecard.
  2. On the right, in the DATA tab of the properties panel, scroll down to the Default Date Range section.
  3. Select Custom, then select a date range.
    Date comparison is not available when the default date range includes all dates in your data set.
  4. Under Comparison date range, choose the comparison period.
  5. Click APPLY.

Comparison periods

Previous period--compares the currently selected period for the chart to the previous matching period. For example, if the current period is Last 28 days, the comparison is to the previous 28 day period prior to the last 28 days.

Previous year--compares the current selected period to the same period last year. For example, if the current period is This week to date (starts Sunday), the chart displays comparison data for the matching dates last year.

Custom--compares the currently selected period to a custom period. By default, the comparison period is fixed, meaning the chart always compares to the exact dates you specify.

The Relative to today option turns a custom comparison period into a rolling date window that advances over time.

Here are some examples:

Assume today's date is January 1, 2019, and the currently selected period for the chart is Last 7 days:

Comparison period Current dates Comparison dates
Previous period December 25, 2018 to December 31, 2018 December 18, 2018 to December 24, 2018
Previous year December 25, 2018 to December 31, 2018 December 25, 2017 to December 31, 2017

Custom

June 1st, 2018 to June 7, 2018

December 25, 2018 to December 31, 2018 June 1, 2018 to June 7, 2018

 

Now, assume today's date is January 2, 2019:

Comparison period Current dates Comparison dates
Previous period December 26, 2018 to January 1, 2019 December 19, 2018 to December 25, 2018
Previous year December 26, 2018 to January 1, 2019 December 26, 2017 to January 1, 2018

Custom

June 1st, 2018 to June 7, 2018

December 26, 2018 to January 1, 2019 June 1, 2018 to June 7, 2018

Custom (Relative to today)

June 1st, 2018 to June 7, 2018

December 26, 2018 to January 1, 2019 June 2, 2018 to June 8, 2018

 

Let viewers change the date

You can enable your viewers to adjust the date range by placing a date range control on the report.

Timezone

Data Studio uses UTC standard time. If your data set doesn't use UTC, you may see discrepancies when charting data for the current day (due to differences between UTC and your timezone).

You can convert a date field to UTC using the TODATE function.
Was this article helpful?
How can we improve it?