Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to substract a day to a date field in Datastudio

Tags:

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

like image 969
Dani Gonzalez Avatar asked Jan 14 '20 07:01

Dani Gonzalez


People also ask

How do you minus days from the date in node JS?

You can use d. setDate(d. getDate() + days) with both positive and negative values for days to add and subtract days respectively.

How do I subtract date from datetime?

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.


1 Answers

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:

like image 185
Nimantha Avatar answered Oct 15 '22 11:10

Nimantha