Chapter 14: Working with Dates, Embedding Content, and Extracting Data
14.7. EXTRACT() and DATE() in Looker Studio
In this lesson, we'll discuss two functions in Looker Studio, EXTRACT()
and DATE()
, that help extract specific date parts from a given date time value. Both methods can be useful in various situations where you only need the date portion of a date time field and not the associated time. If you need to include time to calculate difference between two timestamps, you can check DATETIME_DIFF function in Looker Studio.
Using the EXTRACT() Function
To extract the date part from a datetime value, use the EXTRACT()
function:
EXTRACT(date_part FROM datetime_expression)
In this formula, date_part
should be replaced with the specific part you want to extract from the given datetime expression (e.g., month, week, or date). In our example, we'll extract the date part from the first rebill date calculation:
EXTRACT(date FROM first_rebill_date_expression)
Where first_rebill_date_expression
is the expression used to calculate the first rebill date.
Using the DATE() Function
The DATE()
function is another method that extracts the date from a datetime value:
DATE(datetime_expression)
This function removes the time from the given datetime expression and only returns the date. In our example, we can apply the DATE()
function to the first rebill date calculation:
DATE(first_rebill_date_expression)
Where first_rebill_date_expression
is the expression used to calculate the first rebill date.
These two functions, EXTRACT()
and DATE()
, allow you to isolate specific parts of datetime values in Looker Studio, offering more flexibility in reporting and analysis. They can be especially helpful when you only need the date portion of the datetime value and want to discard the associated time.
📩 Receive my weekly Looker Studio tips
🖇 Connect with me on LinkedIn