Answered step by step
Verified Expert Solution
Link Copied!

Question

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 to Expert-Tailored 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

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

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

Answered: 1 week ago

Question

Solve 2 cos(x) - 3 cos(x) + 1 = 0 for all solutions 0 < x < 2.

Answered: 1 week ago