Create a monthly datetime sequence
Show older comments
Hello everyone,
Can someone please me explain why this code
a=datetime(1981,1,1);
b=datetime(2019,31,1);
t1=a:calmonths(1):b;
t2=datetime(t1,'Format','yyyy-M-d');
M=datevec(t2);
Gives me monthly dates until july 2021? Am I missing something?
Thank you!
1 Comment
t1.Format = 'yyyy-M-d' % the correct way to set the format.
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!