Another solution would be to assign a variable to the starting date, do a repeat cycle where you will add a day to that variable and you will be asking if the date is Saturday, if so you add a + 1 to the counter, the cycle ends when the date you are adding one day reaches the end date. You would have something like that in C #, you would have to spend it no more
public int DiasSabados(DateTime inicio, DateTime fin)
{
int contadorSabados = 0;
while (inicio < fin)
{
if ( inicio.DayOfWeek == DayOfWeek.Saturday)
{
contadorSabados++;
}
inicio = inicio.AddDays(1);
}
return contadorSabados;
}
JavaScript
while(inicio < fin)
{
if (inicio.getDay() == saturday)
{
contadorSabados++;
}
inicio.setDate(inicio.getDate() + 1);
}