MATLAB Answers

datestr generating different string

1 view (last 30 days)
Simon Lind
Simon Lind on 1 May 2021
Commented: Simon Lind on 1 May 2021
I have an array with days, months and years. This is my string
[myd '/' mym '/' myy]
ans =
20/01/2014
But datestr generates this
datestr([myd '/' mym '/' myy])
ans =
06-Jul-0025
Any clue?
Thanks

Accepted Answer

Chad Greene
Chad Greene on 1 May 2021
How about
myy = 2014;
mym = 1;
myd = 20;
datestr(datenum(myy,mym,myd),'dd/mm/yyyy')
ans = '20/01/2014'
  3 Comments
Simon Lind
Simon Lind on 1 May 2021
I just removed the 'string' and now it works
datestr(datenum(([myd '/' mym '/' myy]),'dd/mm/yyyy'))
thank you very much!

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!