Converting integer number of days into date objects in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Converting integer number of days into date objects in python

So, I'm working on a project and I need to find the difference between two dates and I can do that but I get an integer number of days, can I convert that integer into a date object (e.g. 365 days to 1 year) Also why is the Java course broken for me it constantly crashes the app

15th Apr 2017, 4:38 PM
Ontleybot
Ontleybot - avatar
2 Answers
+ 1
Simply assuming 365 days to 1 year might not be the best idea ;-) I'd stay with the timedelta object that you receive from subtraction of two dates. It plays nicely with leap years: https://code.sololearn.com/cHgU1yf1sseb
15th Apr 2017, 5:41 PM
Klaus-Dieter Warzecha
Klaus-Dieter Warzecha - avatar
+ 1
@Klaus-Dieter Warzecha So In your code the difference is 90/91 days but how do you convert that number into a date
15th Apr 2017, 6:43 PM
Ontleybot
Ontleybot - avatar