How to substract time from another time after midnight?
2 ビュー (過去 30 日間)
古いコメントを表示
Asrorkhuja Ortikov
2020 年 8 月 21 日
回答済み: Walter Roberson
2020 年 8 月 21 日
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 件のコメント
採用された回答
Walter Roberson
2020 年 8 月 21 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Earth, Ocean, and Atmospheric Sciences についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!