Convert gregorian day to yyyy-mm

조회 수: 7 (최근 30일)
주희 박
주희 박 2022년 7월 12일
댓글: 주희 박 2022년 7월 13일
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.

채택된 답변

Chunru
Chunru 2022년 7월 12일
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
주희 박
주희 박 2022년 7월 13일
Perfect. Thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by