MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
dt2 = 1x3 duration array
2.5386 days 3.7386 days 4.9386 days

Calculate Elapsed Time in Calendar Units

Use the between function to find the number of calendar years, months, and days
elapsed between two dates.

t1 = datetime('today')

t1 = datetime
13-Apr-2019

t2 = t1 + calmonths(0:2) + caldays(4)

t2 = 1x3 datetime array
17-Apr-2019 17-May-2019 17-Jun-2019

dt = between(t1,t2)

dt = 1x3 calendarDuration array
4d 1mo 4d 2mo 4d

See Also
between | caldiff | diff

7 Dates and Time

Free download pdf