I need to subtract a day from a date field in Datastudio. My date has the DDMMYYYY
format.
You can use d. setDate(d. getDate() + days) with both positive and negative values for days to add and subtract days respectively.
For adding or subtracting Date, we use something called timedelta() function which can be found under the DateTime class. It is used to manipulate Date, and we can perform arithmetic operations on dates like adding or subtracting. timedelta is very easy and useful to implement.
It can now be achieved using the DATETIME_SUB
function (which was introduced in the 17 Sep 2020 update to Dates and Times):
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)
Date - 1
)Date
Google Data Studio Report and a GIF to elaborate:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With