From cc05de331f301102dcaae4711784e0379f3538b8 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 18 Aug 2021 23:42:49 -0700 Subject: [PATCH] Split logic for processing dates vs. strings --- Code.gs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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: -- 2.47.3