Skip to content

Instantly share code, notes, and snippets.

@codykonior
Created May 2, 2022 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codykonior/79d349c81e7a2ff4ca75160a45620535 to your computer and use it in GitHub Desktop.
Save codykonior/79d349c81e7a2ff4ca75160a45620535 to your computer and use it in GitHub Desktop.
let GetPatchTuesday = (timestamp: datetime) {
case(
dayofweek(startofmonth(timestamp) + 07d) == 2d, startofmonth(timestamp) + 07d,
dayofweek(startofmonth(timestamp) + 08d) == 2d, startofmonth(timestamp) + 08d,
dayofweek(startofmonth(timestamp) + 09d) == 2d, startofmonth(timestamp) + 09d,
dayofweek(startofmonth(timestamp) + 10d) == 2d, startofmonth(timestamp) + 10d,
dayofweek(startofmonth(timestamp) + 11d) == 2d, startofmonth(timestamp) + 11d,
dayofweek(startofmonth(timestamp) + 12d) == 2d, startofmonth(timestamp) + 12d,
startofmonth(timestamp) + 13d
)
};
let patchTuesday = case(GetPatchTuesday(now()) <= now(), GetPatchTuesday(now()), GetPatchTuesday(now() - 14d));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment