# I got wrong data when i use datetime convertfrom

조회 수: 4(최근 30일)
주희 박 2022년 9월 15일
편집: 주희 박 2022년 9월 15일
Hi I attached time(year:1999) data. It was nc data so when I use ncdisp, its units = 'hours since 1800-01-01 00:00:0.0'
I tried to convert it by
t=datetime(time,'Convertfrom',datenum);
And I got the answer like
'4780-11-26'
'4780-12-20'
.
.
.
Yeah it is wrong.
How can I get proper 1999 date?

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

### 채택된 답변

Stephen23 2022년 9월 15일
D = S.time
D = 365×1
1744392 1744416 1744440 1744464 1744488 1744512 1744536 1744560 1744584 1744608
T = datetime(1800,1,1) + hours(D)
T = 365×1 datetime array
01-Jan-1999 02-Jan-1999 03-Jan-1999 04-Jan-1999 05-Jan-1999 06-Jan-1999 07-Jan-1999 08-Jan-1999 09-Jan-1999 10-Jan-1999 11-Jan-1999 12-Jan-1999 13-Jan-1999 14-Jan-1999 15-Jan-1999 16-Jan-1999 17-Jan-1999 18-Jan-1999 19-Jan-1999 20-Jan-1999 21-Jan-1999 22-Jan-1999 23-Jan-1999 24-Jan-1999 25-Jan-1999 26-Jan-1999 27-Jan-1999 28-Jan-1999 29-Jan-1999 30-Jan-1999
##### 댓글 수: 1표시숨기기 없음
주희 박 2022년 9월 15일
편집: 주희 박 2022년 9월 15일
Thank you so much! It works well:)

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

### 추가 답변(1개)

Walter Roberson 2022년 9월 15일
dt = hours(t) + datetime('1800-01-01 00:00:0.0')

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

### 범주

Find more on Matrices and Arrays in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by