Convert timedelta to floating-point
I got a timedelta object from the subtraction of two datetimes. I need this value as floating point for further calculations. All that I've found enables the calculation with floating-points, but the result is still a timedelta object. time_d = datetime_1 - datetime_2 time_d_float = float(time_d) does not work. You could use the total_seconds method: time_d_float = time_d.total_seconds() In recent versions of Python, you can divide two timedelta s to give a float. This is useful if you need the value to be in units other than seconds. time_d_min = time_d / datetime.timedelta(minutes=1) time_d