I'm getting data (including date fields) from a Google Sheets document and importing into MongoDB (via Mongo Realm, although I suspect Node, Lambda etc would be the same).
The date field in sheets is data validated as a date (and date is chosen via date picker) but when I console.log the typeof the variable I get in shows as a string with the value like "Thu Aug 20 00:00:00 GMT+01:00 2020".
If I run it through new Date() logging reports it is NaN-aN-aN and when it hits Mongo it shows as 0001-01-01T00:00:00.000+00:00.
Does anyone know how to to get the date in the Google Sheet as a Date in Mongo? The JSON schema on the collection for that field is
"purchase_date": {
"bsonType": "date"
},
I'm also trying to insert a year 2020 into Mongo as a Date type if anyone knows how to specify that?