Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
How to use this JS function in Google Sheets? Using cell values in var and loop

So, I have this one function that calculates the number of Thursdays between two dates:

var startDate = new Date('2021/8/16');
var endDate = new Date('2022/3/15');

function THURSDAYS( days, d0, d1 ) {
  var ndays = 1 + Math.round((d1-d0)/(24*3600*1000));
  var sum = function(a,b) {
    return a + Math.floor( (ndays+(d0.getDay()+6-b) % 7 ) / 7 ); };
  return days.reduce(sum,0);
}

return(THURSDAYS([3],new Date(startDate),new Date(endDate)));

enter image description here

And I'm trying to use it as a custom function in Google Spreadsheet like here where it would return the sum/total of Thursdays found on each line. So I need to use cell values in startDate and enDate, then create a loop... Still learning so I guess I get easily fried up LOL

Anyways, thank you for any help you can give!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You don't need a custom function. Try

=SUMPRODUCT(N(WEEKDAY(ROW(INDIRECT( A2 &":"& B2));2)=4))
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda