Snippet > How to get last Saturday date with Airscript

Hi all,

Quick snippet I crafted in AirScript to get the last Saturday date time, based on a given date time:

SUBTRACT_FROM_DATETIME(
    input_datetime,
    PARSE_NUMBER(FORMAT_DATETIME(input_datetime, "d")) + 1,
    "days"
  )

As Saturday is considered to be the last day of the week. The code subtracts the position of the day in the week from the given date (plus one as the sequence starts with zero).

Hope you find it helpful!

2 Likes