5

I need to subtract a day from a date field in Datastudio. My date has the DDMMYYYY format.

Dani Gonzalez
  • 93
  • 1
  • 7

2 Answers2

3

It can now be achieved using the DATETIME_SUB function (which was introduced in the 17 Sep 2020 update to Dates and Times):

1) Date - 1

Where the field is represented by Date, the following Calculated Field does the trick (subtracting a Day):

DATETIME_SUB(Date, INTERVAL 1 DAY)

2) Type (Date - 1)

Date

Google Data Studio Report and a GIF to elaborate:

Nimantha
  • 6,405
  • 6
  • 28
  • 69
2

DATETIME_SUB can also become more dynamic adding another field or parameter as its second parameter. BUT you have to CAST it as an int64_expression. Example:

DATETIME_SUB(Date_Field, INTERVAL CAST(Numeric_Field AS INT64) DAY)