weekday of last day of a month

3 visualizaciones (últimos 30 días)
Indrani
Indrani el 17 de Jul. de 2023
Comentada: Indrani el 17 de Jul. de 2023
Hi!
How do I find the weekday of the last day of any month in any year?
Thanks!

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 17 de Jul. de 2023
Editada: Dyuman Joshi el 17 de Jul. de 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'

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by