I'm after uploading a dataset to MongoDB with some fields as time. When these were uploaded they went in as strings. Like TOC below:
_id:5dd1a91511a7e24b487bce43
Unit:"Fire"
Date:"01-Jan-13"
TOC:"01:27:19"
I am trying to change these using the Aggregations tool in Compass. I have matched all documents where TOC is not a timestamp:
$match
/**
* query - The query in MQL.
*/
{
TOC: {$not: {$type: 17}}
}
And I am then trying to convert the string to be read as time instead of a string:
$project
/**
* specifications - The fields to
* include or exclude.
*/
{
TOC: {
"$dateFromString": {
"dateString": '$TOC',
"format": "%H:%M:%S"
}
}
}
Getting the error:
an incomplete date/time string has been found, with elements missing: "01:27:19"
Any idea how I can fix this, or if there is a better way to do it?