Convert gregorian day to yyyy-mm

1 vue (au cours des 30 derniers jours)
주희 박
주희 박 le 12 Juil 2022
Commenté : 주희 박 le 13 Juil 2022
Hi, I attached 'Time' variable from 1995-01-01~2021-12-15 and it is monthly data.
It's units = 'days since 1950-01-01 00:00:00
I want to convert it yyyy-mm .
This is what i tried
  1. TT=datetime(1995,1,1)+hours(time); -> It starts 1996-11~
  2. TT=years(time) ->Absolutely wrong
  3. TT=datetime(time,'ConvertFrom','epochtime','Epoch','1950-01-01');->It's unit is seconds. Wrong
Please help me. Thanks.

Réponse acceptée

Chunru
Chunru le 12 Juil 2022
load Time.mat
%time
dt = datetime("1950-01-01 00:00:00") + days(time)
dt = 324×1 datetime array
15-Jan-1995 15-Feb-1995 15-Mar-1995 15-Apr-1995 15-May-1995 15-Jun-1995 15-Jul-1995 15-Aug-1995 15-Sep-1995 15-Oct-1995 15-Nov-1995 15-Dec-1995 15-Jan-1996 15-Feb-1996 15-Mar-1996 15-Apr-1996 15-May-1996 15-Jun-1996 15-Jul-1996 15-Aug-1996 15-Sep-1996 15-Oct-1996 15-Nov-1996 15-Dec-1996 15-Jan-1997 15-Feb-1997 15-Mar-1997 15-Apr-1997 15-May-1997 15-Jun-1997
  1 commentaire
주희 박
주희 박 le 13 Juil 2022
Perfect. 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

Community Treasure Hunt

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

Start Hunting!

Translated by