I have a table with a date
field UTC timezone but I want to change it into another timezone in data studio. I have created a new field in data studio with this formula: TODATE(update_date,"America/Chicago")
but it didn't work correctly. Any ideas? I won't change the source table to add a new column (date convert).
I was looking for an answer to this for a long time and came across so many complex indirect approaches, till I was able to implement something which seems very easy and straight forward.
Basically, in the data source connection you set up the date selection field as:
DATE('your_timefield', @timezone)
In case if using date range parameter, it would be something like:
DATE('your_timefield', @timezone) BETWEEN PARSE_DATE('%Y%m%d', @DS_START_DATE) AND PARSE_DATE('%Y%m%d', @DS_END_DATE)
Next step, create a 'parameter' as below
You can select any of the timezones as 'default'
Now within your report you can publish a drop down giving users option to switch between the timezones
works like a charm. Also, while using it for things like displaying time ( in trends or otherwise) use the same parameter in selecting date/time so the time field reflects the timezone as well. you can use the datetime function as below
DATETIME("your_timefield", @timezone) as your_timefield
Time Zone calculations can now be done in Google Data Studio using the recently introduced ( 17 Sep 2020 Update ) Date and Time functions.
Ensure that the Date field has been upgraded to to the newer Date field type.
Added a GIF to elaborate:
America/Chicago
The Calculated Field below makes use of DATETIME_DIFF
in conjunction with CURRENT_DATETIME
to get the difference between the two Time Zones ( UTC
and America/Chicago
), and then subtracts the difference in SECOND
from the Date field (named Date
in this Report):
PARSE_DATETIME(
"%s",
CAST(CAST(FORMAT_DATETIME("%s", Date)AS NUMBER) - DATETIME_DIFF(CURRENT_DATETIME("UTC"), CURRENT_DATETIME("America/Chicago"), SECOND)AS TEXT))
Google Data Studio Report and a GIF to elaborate:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.