Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Python: Am trying to get time difference between y and x, it gives me -ve value in milliseconds. from datetime import datetime x = 2018-01-28

Python: Am trying to get time difference between y and x, it gives me -ve value in milliseconds. from datetime import datetime x = 2018-01-28 08:58:10.83 y = 2018-01-28 08:58:10.144 x_time = datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f') # 2018-01-28 08:58:10.830000 y_time = datetime.strptime(y, '%Y-%m-%d %H:%M:%S.%f') # 2018-01-28 08:58:10.144000 diff = y_time - x_time duration_milliseconds = round(diff.total_seconds() * 1000) print(duration_milliseconds) # -686 

Result : -686

Expected: 61

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What command may be used to list open ports on your computer?

Answered: 1 week ago