Reputation: 33
I would like to convert timedelta to int so that I can do math with it but I keep getting this error:
numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'true_divide' cannot use operands with types dtype('O') and dtype('<m8[D]')
here is the code:
zeit = datetime(2023, 1, 1)
today = datetime.now()
new_date = zeit-today
days_int=(new_date / np.timedelta64(1, 'D')).astype(int)
Upvotes: 3
Views: 9558
Reputation: 638
if u want to convert only days in int then use new_date.days
Upvotes: 2