Number of days between dates in Python

0 votes
I want to find the number of days between any given two dates. How can I do this in Python?
May 30, 2018 in Python by moon
25 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can use the date module to do this - 

from datetime import date

d1 = date(2012, 5, 22)
d2 = date(2018, 5, 26)
delta = d2 - d1
print(delta.days)
answered May 30, 2018 by Nietzsche's daemon
• 4,260 points

Related Questions In Python

0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2 in Python by anonymous
120 views
+1 vote
1 answer

Print the odd and even factors of a number in Python

x = int(input("Enter any number \n")) print("The factors ...READ MORE

answered Nov 19, 2018 in Python by Nabarupa
147 views
0 votes
1 answer
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
54 views
+4 votes
6 answers
+1 vote
4 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
90 views
0 votes
1 answer

Number division in python

For Python 3, use the // operator: q = ...READ MORE

answered Apr 18, 2018 in Python by Nietzsche's daemon
• 4,260 points
20 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.