weekday of last day of a month

조회 수: 2 (최근 30일)
Indrani
Indrani 2023년 7월 17일
댓글: Indrani 2023년 7월 17일
Hi!
How do I find the weekday of the last day of any month in any year?
Thanks!

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 7월 17일
편집: Dyuman Joshi 2023년 7월 17일
%Current Month
y = 2023;
m = 7;
%Get the date of the last day of the month
day = eomday(y,m)
day = 31
%Get the weekday of the last day of the month
[DayNumber,DayName] = weekday(datetime(y,m,day))
DayNumber = 2
DayName = 'Mon'
Edit - In case you want the long name of the day, simply use -
[DayNumber,DayName] = weekday(datetime(y,m,day), 'long')
DayNumber = 2
DayName = 'Monday'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Automotive에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by