Calculate delta time in seconds

15 次查看(过去 30 天)
i have a table where column 1 is the starttime and column 2 the stoptime. Now i want to insert in column 3 the delta time.
DataBaseA.Starttime = ["28-Jun-2021 05:05:38"]
DataBaseA.Stoptime = ["28-Jun-2021 05:15:38"]
Where each row has different datetimes.
Need a result like
DataBaseA.Deltatime = ["600"]

采纳的回答

Walter Roberson
Walter Roberson 2021-10-28
SaT = datetime(DataaBaseA.Starttime, 'InputFormat', 'dd-MMM-yyyy HH:mm:ss');
StT = datetime(DataaBaseA.Stoptime, 'InputFormat', 'dd-MMM-yyyy HH:mm:ss');
dt = StT - Sat;
DataBaseA.Deltatime = string( seconds(dt) );

更多回答(1 个)

Jan
Jan 2021-10-28
Starttime = "28-Jun-2021 05:05:38";
Stoptime = "28-Jun-2021 05:15:38";
Deltatime = compose("%d", seconds(datetime(Stoptime) - datetime(Starttime)))
Deltatime = "600"

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by