Python program to calculate days between 2 dates

In this python basic program,we will calculate days between 2 dates using datetime library.

Steps to solve the program
  1. From datetime import date().
  2. Pass the date() to the given dates.
  3. Subtract date_2 from date_1 and calculate only days using .days
  4. Print the output.
				
					from datetime import date 

date_1 = date(2023, 1, 5) 
date_2 = date(2023, 1, 22) 

result = (date_2 - date_1).days  
print ("Number of Days between the given Dates are: ", result, "days")  
				
			

Output :

				
					Number of Days between the given Dates are:  17 days
				
			

print the current date in the given format

get the factorial of the given number.

Leave a Comment