How to substract time from another time after midnight?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Asrorkhuja Ortikov
am 21 Aug. 2020
Beantwortet: Walter Roberson
am 21 Aug. 2020
So I have start time and end time of trip (in string) in my data, but sometimes end time exceeds midnight, for example:
start_time = "18:30";
end_time = "00:30";
How can correctly substract them to get the right duration time ? Which means I have to 6 hrs duration instead of 18 hrs.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Aug. 2020
Take the difference as you are now. If the difference exceeds 12 hours, subtract the difference from 24.
Or when you do the conversion to numeric hours and minutes from string object, if the end is less than the first add 24 to the end before taking end minus start.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Earth, Ocean, and Atmospheric Sciences finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!