function day is not working in matlab 2020a

I got the following error while using the function 'day' in matlab 2020a. But its worked in 2016a
>>t =
7.3652e+05
>> day(t)
Check for missing argument or incorrect argument data type in call to function 'day'.

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 21일

0 개 추천

Function day() is defined for datetime input arguments. For example
>> t = datetime('now');
>> day(t)
ans =
21

댓글 수: 4

Prasanth R
Prasanth R 2020년 12월 21일
Thanks for your time. I have time values as double (100x1 double matrix). How can I extract day number from each value? I tried this way but the day numbers are totally changed.
(here tt is my matrix)
tint = int64(tt);
tdate = datetime(tint,'ConvertFrom','yyyymmdd') ;
day_count = day(tdate,'dayofmonth') ;
Ameer Hamza
Ameer Hamza 2020년 12월 21일
What is the format of date stored in 'tt'? What does the number represent?
Prasanth R
Prasanth R 2020년 12월 21일
Issue solved. I removed the line
tint = int64(tt);
and used 'datenum' in datetime function
(tt= my matrix)
tdate = datetime(tt,'ConvertFrom','datenum') ;
day_count = day(tdate,'dayofmonth') ;
Thanks for your valuable time and consideration...
Ameer Hamza
Ameer Hamza 2020년 12월 21일
I am glad to be of help!!!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 12월 21일

댓글:

2020년 12월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by