Notification

This article has moved. Please visit cloud.google.com/looker/docs/studio/ for the most up-to-date content. Learn more about the migration.

您请求访问的页面目前没有您的语言版本。您可以从页面底部选择其他语言,或使用 Google Chrome 的内置翻译功能将网页内容即时翻译成您选择的语言。

WEEK

Returns the week number for a given date.

Sample usage

WEEK(Date)

Syntax

1) Returns the week from a Date value.

WEEK(date_expression)

2) Returns the week from a compatibility mode Date value.

WEEK(X [,format_string])

Parameters

  • date_expression - a Date & Time field or expression.
  • X - a field or expression that evaluates to Text, Number, or compatibility mode Date.
  • format_string - format for X. Optional if X is correctly configured as a semantic date field.

Format strings for compatibility mode dates

Supported date functions accept the following input formats if X is a Text field or expression, or compatibility mode Date:

  • Any valid strptime format is accepted.
  • '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, Sat, 24 May 2008 20:09:47 GMT
  • 'RFC_3339': for example, 2008-05-24T20:09:47Z
  • 'DECIMAL_DATE': same as 'DEFAULT_DECIMAL'

Supported time functions accept the following input format if X is a Number field or expression:

  • 'SECONDS': seconds since Epoch
  • 'MILLIS': milliseconds since Epoch
  • 'MICROS': microseconds since Epoch
  • 'NANOS': nanoseconds since Epoch
  • 'JULIAN_DATE': days since Epoch

Examples

Example formula Input Output
WEEK(Date) Jan 1, 2019 1
WEEK(Date as Text, 'BASIC') 2019/01/01-09:40:45 1
WEEK(Date as Number, 'SECONDS') 1561784874 26

WEEK(Date as lots of Numbers, 'MILLIS')

1562004058620 27

Notes

This function works with both compatibility mode dates and upgraded Date and Date & Time data types.

This function returns the week number since the start of year per the ISO 8601 standard.

Was this helpful?

How can we improve it?
true
What's new in Looker Studio?

Learn about new features and recent changes. Looker Studio release notes live on Google Cloud.

Search
Clear search
Close search
Main menu
8774401224470458332
true
Search Help Center
true
true
true
true
true
102097
false
false