Difference between two dates in python

 Hi!!! guys in this tutorial you are going to learn how to find the difference between the two date in python......

for example the difference between 2000-03-15 to 2000-03-22 is 7 days similarly you are going to find out the difference between any two dates in python..................... please subscribe to my youtube channel-------seekcoding
https://www.youtube.com/channel/UCygS6M-U3vYA8nAZNc8SETw




Source code

import datetime


print('Enter a date in YYYY-MM-DD format')


date1=input('enter date1: ')


year,month,day = map(int, date1.split('-'))


date1=datetime.date(year, month, day)


date2=input('enter date2: ')


year,month,day=map(int,date2.split('-'))


date2=datetime.date(year, month, day)


date= abs(date1-date2)


print(date.days,'days')


This is the code to find the difference between two dates in python..........................


output:










If you have any issues please let me know

Post a Comment (0)
Previous Post Next Post