Take date month year from serial date numbers data

조회 수: 9 (최근 30일)
Linh Dinh
Linh Dinh 2017년 11월 6일
댓글: Peter Perkins 2017년 11월 16일
Hi everyone. I have a time data in serial date numbers form including date, month, year, hour and minute. I want to take date, month, year from this data to create a vector. How can I do that? thank you very much in advance.

답변 (1개)

KL
KL 2017년 11월 6일
편집: KL 2017년 11월 6일
if you have something like,
>> dt = datetime([2017 11 06 08 00 00])
dt =
datetime
2017-11-06
>> res = [dt.Year dt.Month dt.Day]
res =
2017 11 6
or you could use ymd, which is much easier,
>> [y,m,d] = ymd(dt)
y =
2017
m =
11
d =
6
  댓글 수: 1
Peter Perkins
Peter Perkins 2017년 11월 16일
And the hms function is the other half of ymd. Also, the datevec function applied to a datetime array will return all six components as one numeric matrix.

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

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by