Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![wicker](https://secure.gravatar.com/avatar/1b294ee92686e0657279ba482f84a689?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
wicker
2,987 PointsWhat kind of datetimes are you asking me? Now and today?
Here is the task: Write a function named minutes that takes two datetimes and, using timedelta.total_seconds() to get the number of seconds, returns the number of minutes, rounded, between them. The first will always be older and the second newer. You'll need to subtract the first from the second. And I don't get anything with the time. Sadly it is in the end of the course so I can't finish this. I am giving up officially.
import datetime
def minutes(datetime_one, datetime_two):
datetime_one = datetime.datetime.now()
datetime_two = datetime.datetime.now()
return int(timedelta.total_seconds(datetime_one - datetime_two) / 60)
1 Answer
![Mark Sebeck](https://uploads.teamtreehouse.com/production/profile-photos/6569772/micro_mark.jpg)
Mark Sebeck
Treehouse Moderator 37,777 PointsHi Wicker. Good try. This was a difficult question. Few things going on here.
First the datetimes are being passed in so no need to set them to now(). They will have datetime values already. So delete these two lines:
datetime_one = datetime.datetime.now()
datetime_two = datetime.datetime.now()
Next instead of using the function int() you want round(). Because int() will do the same as floor() which is just remove the decimals instead of rounding up when it's greater than equal to .5.
Also timedelta.total_seconds should be datetime.timedelta.total_seconds.
Lastly the question states "The first will always be older and the second newer. You'll need to subtract the first from the second. " Little confusing but it should be datetime_two - datetime_one.
If you still can't get it to pass post your new code back to the Community and someone will help you out. Happy coding!
wicker
2,987 Pointswicker
2,987 PointsThank you! I got this.