If I have two dates (ex. \'8/18/2008\'
and \'9/26/2008\'
), what is the best way to get the number of days between these two dates?
everyone has answered excellently using the date, let me try to answer it using pandas
dt = pd.to_datetime('2008/08/18', format='%Y/%m/%d')
dt1 = pd.to_datetime('2008/09/26', format='%Y/%m/%d')
(dt1-dt).days
This will give the answer. In case one of the input is dataframe column. simply use dt.days in place of days
(dt1-dt).dt.days