I've been experimenting with the aggregate function to group date fields by year:
db.identities.aggregate([
{
$group : {
_id : { year : {$year : "$birth_date"}},
total : {$sum : 1}
}
}
])
However, I encountered a challenge with some dates falling before 1970 which resulted in an error related to gmtime on my Windows system:
{
"errmsg" : "exception: gmtime failed - your system doesn't support dates before 1970",
"code" : 16422,
"ok" : 0
}
Considering potential solutions like running a virtual machine, I'm curious if there are any workarounds specifically for Windows (Windows 7 in this case). If not, I am wondering about the performance impact of storing the date as a nested object:
birth_date : {
year : 1980,
month : 12,
day : 9
}
I am unsure how this might affect indexes and overall database performance.
Seeking advice and suggestions!