datestr generating different string

2 vues (au cours des 30 derniers jours)
Simon Lind
Simon Lind le 1 Mai 2021
Commenté : Simon Lind le 1 Mai 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by