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
39 views

1 answer to this question.

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
213 views
+2 votes
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
849 views
0 votes
2 answers
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 287 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
1,141 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
32 views