question

ydpt avatar image
ydpt asked

snapshot date being last saturday

Hello! :)

I am trying to have SQL run automatic, by always selecting the last Saturday based on the current day.

So as of today (21st Aug), it would need to give me the filter applying to the 19th

The query below is how I run it as of now (manually always changing the date based on last saturday)

....

WHERE idq.snapshot_date = '2023-08-19'

....

thanksydpt

datesqlquery
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered

You need to look at some datemath, go look at the functions dateadd and datediff, a combination of both of these functions will give you a value of the last Saturday based on the current timestamp.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.