MongoDB provides various options for extracting date parts from a date.
This article presents 3 ways to return the week portion from a date in MongoDB.
MongoDB provides various options for extracting date parts from a date.
This article presents 3 ways to return the week portion from a date in MongoDB.
When extracting the day from a date, the exact option we use will depend on how we want the day to be represented.
For example, do we want the day of the week, the day of the month, or the day of the year? Or perhaps we want it in ISO 8601 format? The return value will usually be different depending on which one we choose.
This article explores those options, and therefore presents 8 ways to return the day portion from a date in MongoDB.
MongoDB provides a number of aggregation pipeline operators for working with dates, including operators that extract certain parts of dates, such as the year, month, day, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. You can therefore use JavaScript to extract date values and date parts, etc from a field as required.
This article presents 5 ways to return the month portion from a date in MongoDB.
MongoDB provides quite a few aggregation pipeline operators for working with dates. This includes operators that extract certain parts of dates, such as the year, month, day, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. This therefore allows you to use JavaScript to extract date values and date parts, etc from a field.
This article presents 6 ways to return the year portion from a date in MongoDB.
In MongoDB, the $toUpper aggregation pipeline operator converts a string to uppercase and returns the result.
In MongoDB, the $toLower aggregation pipeline operator converts a string to lowercase and returns the result.
From MongoDB 4.4, you can use the $isNumber aggregation pipeline operator to check whether or not a value is a number.
It accepts any valid expression, and returns true if the expression is a number, false if it’s not.
The $replaceAll aggregation pipeline operator was introduced in MongoDB 4.4.
This operator replaces all instances of a search string in an input string with a replacement string and returns the result.
If the search string isn’t found, then $replaceAll returns the input string.
The $replaceOne aggregation pipeline operator was introduced in MongoDB 4.4.
This operator replaces the first instance of a search string in an input string with a replacement string and returns the result.
If the search string isn’t found, then $replaceOne returns the input string.
MongoDB 4.4 introduced the $last aggregation pipeline operator.
This operator returns the last element in an array.