0

How can I get the number of days since 1/1/1972 with CustomerSince (a data frame) below: 

    CustomerSince
1   2011-07-24 21:27:16.617
2   2011-10-05 21:27:16.617
3   2012-07-24 21:27:16.617
4   2010-08-31 21:27:16.617
5   2011-07-24 21:27:16.617

Thanks for the reply.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
  • 2
    See https://stackoverflow.com/questions/151199/how-to-calculate-number-of-days-between-two-given-dates – Aero Blue Dec 27 '22 at 08:17

1 Answers1

1

If your question is the difference between two dates, This solution may help you:

from datetime import datetime
    
    str_dt1 = '1972/01/01'
    str_dt2 = '2011/07/24'
    
    dt1 = datetime.strptime(str_dt1, "%Y/%m/%d")
    dt2 = datetime.strptime(str_dt2, "%Y/%m/%d")
    
    delta = dt2 - dt1
    print(f'Difference is {delta.days} days') # Difference is 14449 days
Ali Dehkhodaei
  • 426
  • 3
  • 15