" month "

How to use MongoDB date aggregation operators in Node.js with Mongoose ($dayOfMonth, $dayOfYear, $dayOfWeek, etc)

While I was working on creating a tutorial for MongoDB aggregation I came across a few issues while trying to use the built in date aggregation operators.  I was storing the date in the db as the unix epoch timestamp.  I tried multiple variations such as “new Date()”, “new Date().getTime()”, “Date.now()”, etc, but none of those would work.  I kept getting this error “can’t convert from BSON type NumberDouble to Date”.  Turns out, the solution was very simple, and something I completely overlooked (more…)