Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
Script de Google que coincide con la fecha de mañana con una entrada de fecha de formularios de Google

He intentado hacer coincidir la fecha de mañana con la fecha que se envía a través del formulario de Google. en el registrador parece coincidir, pero no registra SÍ y no se evalúa como verdadero.

Mi esfuerzo:

 function ArchiveTuesdayOrder() { let dt = new Date(); let t = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate() + 1);//default for items not provided in the constructor is zero const date = new Date(); date.setDate(date.getDate() + 1); var tom = Utilities.formatDate(date, "America/New_York", 'EEE MMM dd yyyy HH:mm:ss Z'); var tomDate = Utilities.formatDate(date, "America/New_York", "MM-dd-yyyy"); var sheetActive = SpreadsheetApp.openById("xxxxxxxxxxxxxx"); var sheet = sheetActive.getSheetByName("xxxxxxxxxxxxxx"); //var orderDate = sheet.getRange(2,3,100).getValues(); var orderdateRange = sheet.getRange(2, 4, 100); var orderDate = orderdateRange.getValues(); Logger.log(tom.substring(0,10)) Logger.log(t); for (var i = 0; i < orderDate.length; i++) { Logger.log(orderDate[i]) if (t === orderDate[i]) { // This is what I cant get to evaluate true- No Match Logger.log("YES"+orderDate) }}}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

function tomorrow() { let dt = new Date(); dt.setDate(dt.getDate() + 1); Logger.log(dt); return dt.valueOf();//milliseconds can be used in numerical comparisons } function tomorrowstartofday() { let dt = new Date(); let t = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate() + 1);//default for items not provided in the constructor is zero Logger.log(t); return t.valueOf(); }

Aquí hay un pequeño ejemplo de selección de marca de tiempo que ocurre dentro de un día:

Los datos falsos:

marca de tiempo tipo de día
11/10/2021 0:00:00 el dia de ayer
11/10/2021 12:00:00 el dia de ayer
12/10/2021 0:00:00 comienzo del dia
12/10/2021 12:00:00 Este Dia
13/10/2021 0:00:00 mañana
13/10/2021 12:00:00 mañana

El código:

 function timestampsfortoday() { const dt = new Date(); const tod = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf();//today const tom = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate() + 1).valueOf();//tomorrow let ts = []; const ss = SpreadsheetApp.getActive(); const sh = ss.getSheetByName('Sheet0'); const vs = sh.getRange(2,1,sh.getLastRow() - 1,2).getValues(); vs.forEach(r => { let d = new Date(r[0]).valueOf();//using Date() constructor to get date value from timestamp if(d > tod && d < tom) { ts.push(r); } }); Logger.log(ts.join('\n')) }

El registro de ejecución:

 9:58:44 AM Notice Execution started 9:58:46 AM Info Tue Oct 12 2021 12:00:00 GMT-0600 (Mountain Daylight Time),today 9:58:45 AM Notice Execution completed

Solo eligió la fila con hoy en la segunda columna porque es la única entre el inicio del día de hoy y el inicio del día de mañana.

Si usa esta línea para la comparación en el ciclo:

 if(d >= tod && d < tom)

Obtienes esto:

 Execution log 10:05:58 AM Notice Execution started 10:05:59 AM Info Tue Oct 12 2021 00:00:00 GMT-0600 (Mountain Daylight Time),start of day Tue Oct 12 2021 12:00:00 GMT-0600 (Mountain Daylight Time),today 10:05:59 AM Notice Execution completed
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda