A list of python data transformations
- String to Datetime and then compare
#!/usr/bin/python
import datetime
cur = datetime.datetime.now().strftime("%Y-%m-%d")
future = datetime.datetime.strptime(cur + " 16:01:00", "%Y-%m-%d %H:%M:%S")
compare = datetime.datetime.strptime(cur + " 16:02:00", "%Y-%m-%d %H:%M:%S")
print compare > future
print compare < future