Nov-05-2020, 05:23 PM
TO perfringo, I did that just a little bit different way.
I can get time dif in days or just hours or seconds. It is the next, how to calculate exactly total hours per each day.
I can get time dif in days or just hours or seconds. It is the next, how to calculate exactly total hours per each day.
from datetime import datetime, date, time, timedelta lsn = '2020-11-05 19:45:16' fln = '2020-11-03 09:30:16' fmt = '%Y-%m-%d %H:%M:%S' tstamp1 = datetime.strptime(lsn, fmt) tstamp2 = datetime.strptime(fln, fmt) if tstamp1 > tstamp2: td = tstamp1 - tstamp2 tdif = str(td) print ("TIME Difference -----------",tdif) td_mins = int(td.total_seconds() / 60) print ("Time Dif in Minntes --- ", td_mins) td_sec = int(round(td.total_seconds())) print('The difference IN SEONDS ---------%s seconds' % td_sec)