Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save idavidmcdonald/f8fe62085c4bb2d7b17cd997d05551d0 to your computer and use it in GitHub Desktop.
Save idavidmcdonald/f8fe62085c4bb2d7b17cd997d05551d0 to your computer and use it in GitHub Desktop.
from datetime import date, timedelta
start_date = date(2016, 5, 17)
stop_date = date(2019, 9, 30)
date_to_process = start_date
while date_to_process <= stop_date:
print(f"""
delete from notification_history
where created_at <= '{date_to_process}';
""")
date_to_process = date_to_process + timedelta(days=1)
Output:
delete from notification_history
where created_at <= '2016-05-17';
delete from notification_history
where created_at <= '2016-05-18';
.....
....
delete from notification_history
where created_at <= '2019-09-29';
delete from notification_history
where created_at <= '2019-09-30';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment