Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!