date to date month calculation coding

6 次查看(过去 30 天)
input:
starting date: 01/01/2018
End date: today
output:
no. of month calculation: 9
_How to insert coding in M.file matlab

回答(1 个)

jonas
jonas 2018-10-5
编辑:jonas 2018-10-5
dt = caldiff([datetime(2018,1,1);datetime('today')])
dt =
calendarDuration
-9mo -4d
and if you want to extract the month only
calmonths(dt)
ans =
-9

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by