How to find out number of Fridays in a month?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I guess I can use lweekdate and nweekdate. Just wondering if there is a faster way to do this.
0 comentarios
Respuestas (2)
Stephen23
el 11 de Ag. de 2022
Here is a really simple approach using CALENDAR():
M = calendar(2022,8);
N = nnz(M(:,6))
Otherwise you could try using a DATETIME array:
D = datetime(2022,8,1);
V = D:D+calmonths(1)-caldays(1);
N = nnz(weekday(V)==6)
0 comentarios
Cris LaPierre
el 11 de Ag. de 2022
year = 2022;
month = 4;
dt = datetime(year,month,1):caldays(1):dateshift(datetime(year,month,1),'end',"month");
dys = weekday(dt)
nFr = sum(dys==6)
0 comentarios
Ver también
Categorías
Más información sobre Calendar en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!