From MongoDB 4.0, you can use the $toLong aggregation pipeline operator to convert a value to a long.
aggregation
MongoDB $toInt
From MongoDB 4.0, you can use the $toInt aggregation pipeline operator to convert a value to an integer.
MongoDB $toDouble
From MongoDB 4.0, you can use the $toDouble aggregation pipeline operator to convert a value to a double.
MongoDB $toDecimal
From MongoDB 4.0, you can use the $toDecimal aggregation pipeline operator to convert a value to a decimal.
MongoDB $convert
In MongoDB, you can use the $convert aggregation pipeline operator to convert a value to a specified type.
You can convert any valid expression to a double, string, ObjectId, boolean, Date, integer, long, or decimal.
MongoDB NOW Aggregation Variable
MongoDB provides the NOW system variable that allows you to get the current datetime value when using an aggregation pipeline.
This can be useful for when you want to update a document with the current datetime.
MongoDB $dateFromParts
In MongoDB, the $dateFromParts aggregation pipeline operator constructs and returns a Date object from the date’s constituent parts.
You provide each date part as a separate field.
You can specify your constituent date fields in ISO week date format if required.
MongoDB $dateToParts
In MongoDB, the $dateToParts aggregation pipeline operator returns the date parts of a given date.
More specifically, it returns a document that contains the constituent parts of a given BSON Date value as individual properties.
MongoDB $dateToString
In MongoDB, the $dateToString aggregation pipeline operator converts a given date object to a string.
The $dateToString operator accepts either a Date, a Timestamp, or an ObjectId.
MongoDB $dateToString Format Specifiers
The following table outlines the format specifiers that can be used with the $dateToString aggregation pipeline operator in MongoDB.