Skip to main content
WEEK
Tom Williams avatar
Written by Tom Williams
Updated over a year ago

Type: Function

Syntax: WEEK([datetime])

Description: This function has two different modes of operation, based on whether an argument is provided or not. With no arguments, it returns the duration of a week in seconds (604800). With a datetime argument, it returns the week of the year (between 1 and 52) for the provided datetime

Sample usage:

  • WEEK() is equal to 604800

  • WEEK(created_at) returns the week of the year for the created_at field value

  • WEEK(DATE(2023, 08, 27)) returns 34.

  • AVG(closed_at-created_at)/WEEK() returns the time elapsed in weeks between the creation and closing of a record. Note that the difference between two dates (closed_at-created_at) is always returned in seconds.

  • created_at + 2*WEEK() returns the created_at field value plus 2 weeks (14 days).

Did this answer your question?