I have three variables
a = 1
b = 2
c = 3
Every day, I need to add 1 to each variable
a = a 1 (so a=2)
b = b 1
c = c 1
But I need that when tomorrow I run the script, to add 1 unit more:
a = a 2 (so tomorrow a=3, after 2 days a = 4....)
b = b 2
c = c 2
And so on...I need every day to add 1.
Any ideas?
CodePudding user response:
Choose some fixed reference date, and when the code runs, calculate the number of days from the reference date, adjust by some constant offset, and add that to your variables. So, maybe I choose 1/1/2022 as my reference date and an offset of 100 days. This means on 100 days after 1/1/2022 the variables don't get increased at all, 101 days after 1/1/2022 the variables are greater by 1, and so on.
If you need to only increase if the script actually ran on a date, keep a log file of days the script actually ran, or for that matter, save the increments directly!