Python defined variables with dates as "string", how do I convert it to the right type for comparison?
Dates in variables:
today - 2019,01,16
server - 2018,11,11
import subprocess import datetime from datetime import datetime, date, timedelta server = subprocess.check_output("ΠΊΠΎΠΌΠ°Π½Π΄Π°_ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ", shell=True).decode('utf-8').strip() today = datetime.today().strftime("%Y,%m,%d") startDay = (today-server) print(startDay.days) Conclusion:
Traceback (most recent call last): File "test.py", line 15, in <module> startDay = (today-server) TypeError: unsupported operand type(s) for -: 'str' and 'str'
today-server- gil9red 1:54 pmstartDay = (today-server)withstartDay = datetime.strptime(today, "%Y,%m,%d") - datetime.strptime(server, "%Y,%m,%d")- S Nick'2019,01,16' > '2018,11,11'- insolor