Convert gregorian day to yyyy-mm

4 次查看(过去 30 天)
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

更多回答(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