We convert quite a bit in our dataset and that is of course all right.
However if you just need a simple conversion like this one, where you don't specify on error and on null,
then you can also use a shortcut,
there are some special operators in mongodb
and of course you find them in the official docs under aggregation pipeline operators. There you find if
you scroll down to T, to date, to decimal, to double, to int, to long and so on operators,
so these are shortcuts if you need to do a specific transformation.
So in my case here where I don't have on error and on null, I could just say to date here and simply pass
in the field which holds the date value I want to transform, just like that
and this will yield the same output as we had before.
If I execute this, you see we still have an ISO date but now it's a bit shorter,
so be aware of these shortcuts for simple transformations.
If you do want to specify your own on error and on null fallback because you might have incomplete data
in your dataset, then using these shortcuts is a bit more difficult,
you at least have to check their docs to see if the default value is they will assume are all right
for you.