Why am I getting the following datetime error message?

7 vues (au cours des 30 derniers jours)
Gen Gemond
Gen Gemond le 2 Déc 2021
Commenté : Gen Gemond le 3 Déc 2021
Hello all,
Here is the message I am receiving:
Unable to convert the text to datetime using the format 'yyyy-MM-dd'T'hh:mm:ss.sssZ'.
I am pretty confused about this, as I have an array of UTC dates (and these are strings) that look like the following:
'2017-09-05T00:00:31.256928000Z'
And, so far as I know, this looks just like the format datetime requires. Could someone please point me in the right direction as to what is going wrong? Thank you in advance!! :)
My file is attached, and here is my code:
filename = 'RSPB_MAGNETOMETER2.xls'; %data courtesy of NASA SPDF, Craig Kletzing
A2 = readtable(filename);
Brms2 = table2array(A2(:,2));
dateVec2 = table2array(A2(:,1));
dates2 = datetime(dateVec2,'InputFormat','yyyy-MM-dd''T''hh:mm:ss.sssZ','TimeZone','UTC');
figure(2)
hold on
ylim([0, 100])
xlim([0, 65536])
plot(dates2, Brms2)
xlabel('counts')
ylabel('B_(rms), nT')
hold off

Réponse acceptée

Eric Sofen
Eric Sofen le 3 Déc 2021
I think it's just a typo in your timestamp format spec: ss.sssZ should be ss.SSSZ
  1 commentaire
Gen Gemond
Gen Gemond le 3 Déc 2021
That did the trick, thank you so 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

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by