MATLAB Answers

how can i convert duration type to datetime type??

조회 수: 135(최근 30일)
woongki park
woongki park 18 Aug 2018
답변: Peter Perkins 24 Aug 2018
is there some way?

  댓글 수: 0

로그인 to comment.

답변(2개)

SK
SK 18 Aug 2018
duration is the difference between two datetime objects. So if you know a start date, you can add a duration to it to get the end date. So for example:
>> startdate = datetime(2000, 1, 1);
>> dur = duration(5000, 25, 0);
>> enddate = startdate + dur;
>> enddate
enddate =
datetime
27-Jul-2000 08:25:00

  댓글 수: 0

로그인 to comment.


Peter Perkins
Peter Perkins 24 Aug 2018
As posed, this question is equivalent to, "how do I convert 1 hour to a date?" As SK points out, you also have to answer, "1 hour from what?" And he's provided the solution.
Specific case: It may be that you have durations that represent times of day. If they are all today, for example, then
d = datetime('today') + dur;

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by