I want to add two datetime objects.
>>> from datetime import datetime
>>> a = datetime.strptime("04:30",'%H:%M')
>>> b = datetime.strptime("02:30",'%H:%M')
>>> a
datetime.datetime(1900, 1, 1, 4, 30)
>>> b
datetime.datetime(1900, 1, 1, 2, 30)
when i subtract b from a, it gives me the output
>>> a-b
datetime.timedelta(0, 7200)
but, when i add a and b it gives me error
>>> a+b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'datetime.datetime'
I want to add the time of b to time of a, i.e i want this.
datetime.datetime(1900, 1, 1, 7, 00)
please help ?
bnot a datetime object, but a timedelta object.