K
K
Kwad2020-05-18 15:02:23
Python
Kwad, 2020-05-18 15:02:23

How to add time to time python('datetime.datetime' and 'datetime.datetime')?

Hello everyone, I have a problem with adding time:

today = timezone.now()
added_days = today + timezone.timedelta(days=int(Sub.objects.get(id=qp.desc).duration))
print(today + added_days)

mistake
print(today + added_days)
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'datetime.datetime'

How to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-05-18
@galaxy

print(added_days)
In added_days there is already a date with added days, why add today to it?

D
Dr. Bacon, 2020-05-18
@bacon

How about thinking logically? what will happen if January 1, 2020, add January 3, 2023?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question