Looker Studio is now called Data Studio. Learn more about this change.

TODATE

Returns a formatted compatibility mode date.

You can use TODATE in 2 ways:

  • Create a compatibility mode date from Text fields.
  • Change the display format and granularity of a compatibility mode date.

Sample usage

TODATE(Text_Date,"%Y/%m/%d","%Y-%m-%d")

TODATE(Text_Date,"%Y/%m/%d","%Y-%m-%d")

TODATE(Response_Time, 'MILLIS', '%Y%m%d')

TODATE(Created_Time, 'DECIMAL_DATE', '%Y')

Syntax

TODATE(field_expression, input_date_format, output_date_format)

Input formats

input_date_format is optional if field_expression is correctly configured as a semantic date.

TODATE accepts the following input format strings.

  • 'BASIC': %Y/%m/%d-%H:%M:%S

  • 'DEFAULT_DASH': %Y-%m-%d [%H:%M:%S]

  • 'DEFAULT_SLASH': %Y/%m/%d [%H:%M:%S]

  • 'DEFAULT_DECIMAL': %Y%m%d [%H:%M:%S]

  • 'RFC_1123': for example, 2008年5月24日 20:09:47 GMT

  • 'RFC_3339': for example, 2008年05月24日T20:09:47Z

  • 'SECONDS': seconds since Epoch

  • 'MILLIS': milliseconds since Epoch

  • 'MICROS': microseconds since Epoch

  • 'NANOS': nanoseconds since Epoch

  • 'JULIAN_DATE': days since Epoch

  • 'DECIMAL_DATE': same as 'DEFAULT_DECIMAL'

  • Any valid strptime format. Optional if the value is already a datetime field.

Output formats

TODATE accepts the following output format strings:

  • "%Y" - year
  • "%m" - month
  • "%d" - day
  • "%W" - yearweek number
  • "%w" - day of week
  • "%H" - hour
  • "%M" - minute

Examples

Example formula Input Output
TODATE(Text_Date,"%Y/%m/%d","%Y-%m-%d") 2024年05月09日 2024年05月09日
TODATE(Response_Time, 'MILLIS', '%Y%m%d') 1715294861000 20240509
TODATE(Created_time, 'DECIMAL_DATE', '%Y') 20240509[11:34:12] 2024

Notes

TODATE returns compatibility mode Date data types.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年08月26日 UTC.