Notification

This article is about Looker Studio. For Looker documentation, visit https://cloud.google.com/looker/docs/intro.

Trang bạn đã yêu cầu hiện không có sẵn bằng ngôn ngữ của bạn. Bạn có thể chọn ngôn ngữ khác ở cuối trang hoặc dịch nhanh mọi trang web sang ngôn ngữ mà bạn chọn bằng cách sử dụng tính năng dịch được tích hợp sẵn trong Google Chrome.

DATETIME_SUB

Subtracts a specified time interval from a date.

Sample usage

DATETIME_SUB(Order Date, INTERVAL 1 WEEK)

Syntax

DATETIME_SUB(datetime_expression, INTERVAL integer part)

Parameters

  • datetime_expression - a Date or a Date & Time field or expression.
  • integer - a whole numeric field or expression representing the number of parts to subtract.
  • part - the unit of time measurement to subtract. DATETIME_ADD supports the following values for part:
    • MICROSECOND: available for Date & Time fields or expressions.
    • MILLISECOND: available for Date & Time fields or expressions.
    • SECOND: available for Date & Time fields or expressions.
    • MINUTE: available for Date & Time fields or expressions.
    • HOUR: available for Date & Time fields or expressions.
    • DAY
    • WEEK: This date part begins on Sunday.
    • ISOWEEK: Uses ISO 8601 week boundaries. ISO weeks begin on Monday.
    • MONTH
    • QUARTER
    • YEAR
    • ISOYEAR: Uses the ISO 8601 week-numbering year boundary. The ISO year boundary is the Monday of the first week whose Thursday belongs to the corresponding Gregorian calendar year.

Return data type

Date & Time

Examples

Example formula Output
DATETIME_SUB(DATETIME "2008-12-25 15:30:00", INTERVAL 10 MINUTE) 2008-12-25 15:20:00
DATETIME_SUB(DATE "2008-12-25", INTERVAL 5 DAY) 2008-12-20

Notes

This function is not available for compatibility mode date types.

Special handling is required for MONTH, QUARTER, and YEAR parts when the date is at (or near) the last day of the month. If the resulting month has fewer days than the original Date or Date & Time's day, then the result day is the last day of the new month.

Related resources

Thông tin này có hữu ích không?

Chúng tôi có thể cải thiện trang này bằng cách nào?
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
2877114976702357937
true
Tìm kiếm trong Trung tâm trợ giúp
true
true
true
true
true
102097
false
false