Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get year from date in mongodb

db.cats.aggregate(
   [
     {
       $project: {
          _id: 0,
          formattedDate: { $dateToString: { format: "%Y", date: "$born" } }
       }
     }
   ]
)
Source by database.guide #
 
PREVIOUS NEXT
Tagged: #year #date #mongodb
ADD COMMENT
Topic
Name
3+2 =