I am trying to subtract two timestamps using datetime library of python. Since I don't want date to be included, I removed the date part from below code. Everything comes perfect in the output but at some places output like "-1 day, 23:59:58.233000" is coming. Do anyone have idea how to fix it? I want only time difference not the date. Below attached is the code and its output.
Code:-
d1 = datetime.strptime(c1,"%H:%M:%S.%f")
d2 = datetime.strptime(c2,"%H:%M:%S.%f")
c=(d1-d2)
print(c)
Note: c1 and c2 contains timestamps. Total 37.
Output:-
0:00:03.733000
0:00:03.533000
0:00:03.666000
0:00:05.900000
0:00:04.334000
0:00:03.734000
0:00:04.734000
0:00:04.301000
0:00:10.667000
0:00:13.167000
0:00:11.234000
0:00:08.101000
0:00:10.966000
0:00:02.734000
0:00:03.134000
0:00:06.666000
0:00:06.733000
0:00:02.300000
0:00:00.700000
0:00:00.866000
0:00:02.367000
0:00:02.534000
0:00:01.168000
0:00:00.467000
-1 day, 23:59:55.600000
-1 day, 23:59:57.366000
-1 day, 23:59:58.434000
-1 day, 23:59:58.233000
0:00:00.334000
0:00:04.366000
0:00:01
-1 day, 23:59:58.034000
-1 day, 23:59:57.400000
-1 day, 23:59:55.267000
-1 day, 23:59:54.999000
-1 day, 23:59:53.933000
-1 day, 23:59:55.200000