]> git.ardis.lu - sheets-db/commitdiff
Split logic for processing dates vs. strings
authorArdis Lu <ardisglu@gmail.com>
Thu, 19 Aug 2021 06:42:49 +0000 (23:42 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 19 Aug 2021 06:42:49 +0000 (23:42 -0700)
Code.gs

diff --git a/Code.gs b/Code.gs
index 5fe017e65c6da5d68af69f8094412f9b5a20d932..06a9cb314f0ebb1cb7b2b31f5f6357a5bbc737ec 100644 (file)
--- 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:
This page took 0.04071 seconds and 4 git commands to generate.