我需要从星期数中获取星期开始日期,在下面的查询中,我只能获取特定日期的星期数(ModifiedOn)。我如何使用mongo查询获取Weekstart日期星期几。
需要星期开始日期而不是星期编号
db.userstoryaggregateview.aggregate([
{
"$group": {
"_id": {
"ClientUId": "$ClientUId",
"DeliveryConstructUId": "$DeliveryConstructUId",
"ReleaseUId": "$ReleaseUId",
"IterationUId": "$IterationUId",
"TeamAreaUId": "$TeamAreaUId",
"Week" : { $week : "$ModifiedOn" }
},
"UserStory-SPEstimatedTotalWeekly": {
"$sum": {
"$cond": [
{
"$eq": [
"$UserStory-StoryPointEstimatedTotal",
""
]
},
NumberInt("0"),
{ $toDouble: "$UserStory-StoryPointEstimatedTotal" }
]
}
}
}
},
{
$project: {
"_id": NumberInt("0"),
"ClientUId": "$_id.ClientUId", "DeliveryConstructUId": "$_id.DeliveryConstructUId",
"ReleaseUId": "$_id.ReleaseUId", "IterationUId": "$_id.IterationUId", "TeamAreaUId": "$_id.TeamAreaUId",
"Value": "$UserStory-SPEstimatedTotalWeekly",
"Week":"$_id.Week",
weekStart: { $dateToString: { format: "%Y-%m-%d", date: { // convert date
$subtract: ["$ModifiedOn", {$multiply: [ {$subtract:[{$isoDayOfWeek: "$ModifiedOn"},1]}, 86400000]}]
}}},
}
}], { allowDiskUse: true, cursor:{ batchSize: 101} });