google apps script - How to handle date format for a possibly empty cell? -


from google form have created, 50% of users entering date answer question, other 50% not entering cell contents in response form empty. have written code puts contents of cell format.

i'm exporting data google doc, @ moment if date not entered, "thu 01 jan 1970" appears output. "n/a" instead.

i've left out of code don't think of use:

var enddate = vs.getrange(vlastrow,12); var venddatevalue = new date (enddate.getvalues()); var venddateformat = utilities.formatdate(venddatevalue, 'bst', 'eee dd mmm yyyy'); 

you need test value read spreadsheet first:

var enddate = vs.getrange(vlastrow,12); var cellcontent = enddate.getvalue(); var venddatevalue = new date (cellcontent); var venddateformat = cellcontent ?                       utilities.formatdate(venddatevalue, 'bst', 'eee dd mmm yyyy') :                      "n/a"; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -