Hi team.
I am battling to convert a string to date. I currently manually pass a string date to my program(cobdate = string.replace(sys.argv[1], '-', '')) which will be used by a lot of things. The date will be in this format. "2012-02-02". I need to convert this to a proper date I can use to calculate how many days are between today's date(now = datetime.date.today()) and the date passed to the method by the user
import os
import datetime
import time
import logging
import sys
import platform
import string
sys.path.append('C:\Scripts\Python\sftpsync')
now = datetime.date.today()
TT="2012-01-16"
TT.split()[0]
print TT
aa = now/TT #I want to check how many days there are between the date passed to the method and today's date
print aa
Problem is that I cannot use "aa = now-TT" because TT is a string. I also tried (TT = datetime.strptime('2012-01-16', '%Y-%m-%d')) but they are all not working. What am I missing here. When I print now, it comes up as 2012-02-29. Thank you so much in advance