So I need to make a variable in python to have it send off today's date two years ago. I am having to automate a report in Salesforce using Selenium and need to have the form created by a send.keys() method from a variable.
The variable I have for today's date is :
from datetime import date
import time
today = date.today()
current_date = today.strftime("%m/%d/%Y")
However, I need the past date to be that value printed from two years ago.
from datetime import date
import time
today = date.today()
past_date = today.strftime("%m/%d/%Y") - 2*(365)
However, I get this output:
>>> past_date = today.strftime("%m/%d/%Y") - 2*(365)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'str' and 'int'
I presume it has something to with integer operations and string operations being in the same variable, thereby causing a string mismatch. Does anyone have a solution to help me get the date from two years ago in a dynamic way?