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

330
Vistas
Trying to send email from google sheets with apps script, but blank cells give unwanted output

I'm trying to send some values in table to an email, the problem starts when it sends the date, I want it in this format "dd-mm-yy"

var fecha = new Date(registro.getRange("c16").getValue());
var fechaF = Utilities.formatDate(fecha, "GMT","DD-MM-YYYY");

The above code is used to transform the date, but when a cell that is a date is empty it sends me a date totally random.

It is table with multiple dates, and if I write the first it sends exactly the same, but if there is nothing it sends me a random date, and I want to send nothing, because having these dates in the email could be confusing.

What can I do to set the format, but also to not send anything if it is empty

enter image description here

Here is an example what is send to the email

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this:

var fechaF = registro.getRange("c16").isBlank() ? "No Date" : Utilities.formatDate(new Date(registro.getRange("c16").getValue()), "GMT","DD-MM-YYYY");
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