Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date difference in minutes in Python

How do I calculate the difference in time in minutes for the following timestamp in Python?

2010-01-01 17:31:22 2010-01-03 17:31:22 
like image 378
Hulk Avatar asked May 07 '10 13:05

Hulk


People also ask

How do I find the difference between two dates and minutes in Python?

Use datetime. strptime() to parse into datetime instances, and then compute the difference, and finally convert the difference into minutes.

How do you find the difference between two dates in minutes?

We subtract time/dates in excel to get the number of days. Since a day has 1440 (24*60) minutes, we multiply the result by 1440 to get the exact number of minutes.

How do you calculate minutes in Python?

Get the minute value To calculate the value of minutes we need to first divide the total number of seconds by 3600 and take the remainder. Now to calculate the value of minutes from the above result we will again use the floor operator. A minute has sixty seconds hence we floor the seconds value with 60.


1 Answers

minutes_diff = (datetime_end - datetime_start).total_seconds() / 60.0 
like image 146
Evalds Urtans Avatar answered Oct 14 '22 03:10

Evalds Urtans