help writing a script that tells the day of the week
이전 댓글 표시
I need help writing a code that tells me the day of the week as well as the number of the day relative to the year. Ex: input form month/day/year: xx/xx/xxxx output should say something like: The date 08/31/2011 is the 243 day of the year and is a wednesday.
I have tried so many different things from Mathworks with no luck.
댓글 수: 2
John D'Errico
2015년 10월 10일
disp('Today is Monday")
Correct at least once a week. Oh. did you want it to get the day right, all the time?
bachir
2015년 10월 10일
채택된 답변
추가 답변 (1개)
Peter Perkins
2015년 10월 10일
... and another way, using datetime (if you have R2014b or later):
>> d = datetime('08/31/2011','InputFormat','MM/dd/yyyy')
d =
31-Aug-2011
>> day(d,'dayofyear')
ans =
243
>> day(d,'name')
ans =
'Wednesday'
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!