MongoDB存儲(chǔ)的日期格式是2018-07-01T00:00:00Z問(wèn)題出現(xiàn)的環(huán)境背景及自己嘗試過(guò)哪些方法相關(guān)代碼collection.find_one(
{ "regDate":
{ "$gte":ISODate("2018-07-01T00:00:00Z"),"$lt":ISODate("2018-07-31T00:00:00Z")
}
}
)Traceback (most recent call last): File "<stdin>", line 5, in <module>
NameError: name 'ISODate' is not defined
2 回答

阿晨1998
TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊
ISODate是mongo命令行里用的,python里可用datetime。
from datetime import datetime collection.find_one( { "regDate": { "$gte": datetime(2018, 6, 1), "$lt": datetime(2018, 7, 31) } } )
- 2 回答
- 0 關(guān)注
- 1339 瀏覽
添加回答
舉報(bào)
0/150
提交
取消