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.
Continue reading