Calculate the Days Between Two Dates

Python

In this example we calculate the days between the current date and the date an order was placed in the orders dataframe.

 1|  import datetime as dt
 2|  
 3|  orders['today'] = pd.to_datetime(dt.date.today())
 4|  orders['days_since_order'] = (orders['today'] - orders['Order_Date']).dt.days
Did you find this snippet useful?

Sign up for free to to add this to your code library