From: Ardis Lu Date: Thu, 19 Aug 2021 06:42:49 +0000 (-0700) Subject: Split logic for processing dates vs. strings X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=cc05de331f301102dcaae4711784e0379f3538b8;p=sheets-db Split logic for processing dates vs. strings --- diff --git a/Code.gs b/Code.gs index 5fe017e..06a9cb3 100644 --- a/Code.gs +++ b/Code.gs @@ -69,7 +69,13 @@ function generateDatabaseQuery() { break; case 'TEXT': case 'BLOB': - values += `'${row[col].toString().replace(/'/g, "''")}',`; // Escape apostrophe with double aprostophe + const data = row[col]; // Can be string or date object + if (data instanceof Date) { + values += `'${data.toISOString()}',`; + } + else { + values += `'${data.replace(/'/g, "''")}',`; // Escape apostrophe with double apostrophe + } break; case 'NULL': default: