【发布时间】:2019-10-04 21:43:36
【问题描述】:
我想提取所有在 NVL(修改日期,创建日期)之后具有给定日期的订单。
modifiedDateTime 和 createdDateTime 不遵循大多数其他日期字段,我似乎无法弄清楚如何对它们进行操作符。 并非所有记录都有 modifiedDateTime,所以当它丢失时,我想退回到 createDateTime。 .我尝试了一些东西,但无法获得任何数据逻辑来测试它。
- 在以下位置查找所有记录:
- 示例值:2018 年 8 月 24 日星期五 23:25:16 UTC
- 如果 modifiedDateTime 存在:日期 > modifiedDateTime
- 如果 modifiedDateTime 不存在:日期 > createdDateTime
- SQL 版本:WHERE NVL(modifiedDateTime, createdDateTime) > '30-SEP-2019'
我尝试了以下但没有成功:
db.getCollection('createProvisionServiceOrderRepositoryRequest').find(
{
'modifiedDateTime': {
'$ifNull': [
{'$gte': new ISODate("2019-09-30T00:00:00.000Z")},
{'createdDateTime': {'$gte': new ISODate("2019-09-30T00:00:00.000Z")}}
]
}
}
).count()
两个文档示例:
{
"_id" : "CANO-857098021127729",
"_class" : "yyyy",
"customerOrderNumber" : "xxxx",
"billingAccountNumber" : "123",
"version" : "1",
"customerServiceOrderStatus" : "REJECTED",
"createdDateTime" : "Mon Sep 04 17:35:41 IST 2017"
}
{
"_id" : "CUMO-971416171118821",
"_class" : "yyyy",
"customerOrderNumber" : "xxxx",
"provisioningServiceOrder" : [
{
"_id" : "string",
"provisioningServiceOrderObject" : "Test Data",
"status" : "string",
"correctionList" : [
{
"correctionType" : "string",
"correctionName" : "string",
"correctionAction" : "string",
"correctionOldValue" : "string",
"correctionNewValue" : "string",
"attributeList" : [
{
"attributeType" : "string",
"attributeName" : "string",
"attributeAction" : "string",
"attributeOldValue" : "string",
"attributeNewValue" : "string"
}
]
}
]
}
],
"customerServiceOrderStatus" : "completed",
"modifiedDateTime" : "Wed Sep 06 07:15:47 UTC 2017"
}
【问题讨论】:
标签: mongodb