weekday of last day of a month

3 Ansichten (letzte 30 Tage)
Indrani
Indrani am 17 Jul. 2023
Kommentiert: Indrani am 17 Jul. 2023
Hi!
How do I find the weekday of the last day of any month in any year?
Thanks!

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 17 Jul. 2023
Bearbeitet: Dyuman Joshi am 17 Jul. 2023
%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'

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by