last_week

Returns a range of the most recent full week starting from Sunday or some other day you specify. Can only be used as a range parameter in for_date_range().

The time range selected for a report does not affect this function. That is, no matter what time range is selected for a report, this function always returns the most recent full week based on today's date.

Syntax

last_week([startDay])

Parameter

  • startDay: Optional. An integer (1 through 7) that specifies which day you consider to be the first day of the week:
    • 1 = Sunday
    • 2 = Monday 
    • 3 = Tuesday
    • 4 = Wednesday
    • 5 = Thursday
    • 6 = Friday
    • 7 = Saturday

By default, Sunday is the starting day.

Examples

  • Clicks.for_date_range(last_week()): Returns the number of clicks from the most recent Sunday to Saturday range.
    last_week() selects the most recent Sunday to Saturday range
  • Clicks.for_date_range(last_week(2)): Returns the number of clicks from the most recent Monday to Sunday range.
    last_week(2) selects the most recent Monday to Sunday range
Was this helpful?
How can we improve it?