Complete the code to extract the year from the date field.
{ $project: { year: { $[1]: "$date" } } }The $year operator extracts the year part from a date.
Complete the code to extract the month from the date field.
{ $project: { month: { $[1]: "$date" } } }The $month operator extracts the month number (1-12) from a date.
Fix the error in the code to extract the day of the month from the date field.
{ $project: { day: { $[1]: "$date" } } }The correct operator to get the day of the month is $dayOfMonth.
Fill both blanks to extract the year and month from the date field.
{ $project: { year: { $[1]: "$date" }, month: { $[2]: "$date" } } }Use $year to get the year and $month to get the month from a date.
Fill all three blanks to extract year, month, and day of the month from the date field.
{ $project: { year: { $[1]: "$date" }, month: { $[2]: "$date" }, day: { $[3]: "$date" } } }Use $year, $month, and $dayOfMonth to extract the respective parts from a date.
