I’m struggling to create Charts with data that have date information.
Our data is saved as String type, for example:
“Tue Jan 10 2023 12:33:40 GMT+0000 (Coordinated Universal Time)”
If I try to use this directly in a Chart, automatic binning does not work, and I’m not sure how to provide a regex that automatically does binning for day, month, year options.
If I convert the type to Date in the Charts UI, the binning options appear, but the Chart does not load saying 'Invalid Date".
Dates as Date data type take less space than strings.
Dates as Date data type perform better than strings.
Dates as Date data type provide a rich date specific API without the need to convert every time.
Hopefully you control the code that creates document. So it should be easy. Otherwise it should be
easy to write a change stream handler that automatically convert date string as date date.
I do control the creation of the objects, but I am not sure why they aren’t already saved as Date type, here is the node.js code for saving Date() with mongoose 5.13.15: