Hello everyone,
I have a database that contains data from early 2019 to April 2023.
I created a script that when I run it again adds new data for 2023 every week.
To prevent this file from becoming too heavy, I would like when I restart the script at the beginning of the week to be able to delete a rolling week.
For example today we are in week 21 (W21) of 2023. When I run the script today, I can delete the S1 of 2019 and then add the S21 of 2023.
Next week we will be in S22 2023, the script will add this new week, at the same time I would like to be able to delete the S2 of 2019, so on...
However, if I run the script several times in the same week, it should not delete several consecutive weeks.
Example : If I run the script 3 times in S21 2023, it just deletes S1 2019 and not S1/S2/S3 2019 (because I ran the script 3 times)
I have a "Start date" column in my database which will be useful for the development of the script. Here is an overview of the column below:

Thanks for your help