Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python calc days between dates

from datetime import date

d0 = date(2008, 8, 18)
d1 = date(2008, 9, 26)
delta = d1 - d0
print(delta.days)
Comment

days calculator python

import datetime
def Days_Calculator():
    '''create a python function that takes 2 dates and prints how
    many days between the 2 dates'''
    fdate, ldate = input("enter first date :"), input("enter second date :")
    # enter first date :24 2 2022
	# enter second date :13 10 2022
    fdate, ldate = fdate.split(" "), ldate.split(" ")
    date_1 = datetime.date(int(fdate[-1]), int(fdate[1]), int(fdate[0]))
    date_2 = datetime.date(int(ldate[-1]), int(ldate[1]), int(ldate[0]))
    delta = date_2-date_1
    print(f"number of days is {delta.days} ")
    # number of days is 231 
Days_Calculator()
Comment

PREVIOUS NEXT
Code Example
Python :: how to replace a character in python 
Python :: python find last index of character in string 
Python :: *args in python 
Python :: dataframe 
Python :: python / vs // 
Python :: convert dictionary to string 
Python :: python sort array by lambda 
Python :: start and end index in python 
Python :: pygame buttons 
Python :: bounding box in python 
Python :: pyton for 
Python :: how to print memory address in python 
Python :: how to print from a python list 
Python :: pandas to excel 
Python :: python3 create list from string 
Python :: create dictionary python having hash value 
Python :: counter method in python 
Python :: get end of string python 
Python :: if we use list in the dictionary 
Python :: how to create a subset of a dataframe in python 
Python :: pandas remove duplicates 
Python :: while loop in python for do you want to continue 
Python :: lineplot in plt 
Python :: drop null values in dataframe 
Python :: Finding the maximum element from a matrix with Python numpy.argmax() 
Python :: how to reduce the image files size in python 
Python :: how to make a do while in python 
Python :: -2 in python 
Python :: get source selenium python 
Python :: code optimization in python 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =