One of those fields is a date
object, the other a datetime
object. You'll have to decide what you want subtraction to mean.
You could, for example, turn the date
object into a datetime
object with a fixed time of day, say, midnight:
los = ads - datetime.datetime.combine(dds, datetime.time.min)
datetime.datetime.combine()
takes a date
and a time
object and creates a new datetime
object; we use datetime.time.min
as an easy short-cut to a time
object representing midnight.
Or, you could just turn the datetime
object into a date
object and then subtract:
los = ads.date() - dds
The datetime.date()
method returns just the date component of a datetime
object. The result is a datetime.timedelta()
object representing the number of days between the two dates.