ISODate日期类型查询
ISODate是GMT(格林威治标准时间),比我所处时间早8小时(毫秒忽略)。
关系 | Mongo表达式 | 描述 |
---|---|---|
大于 | $gt | greater than |
大于等于 | $gte | greater than or equal to |
小于 | $lt | less than |
小于等于 | $lte | less than or equal to |
等于 | equal to | |
不等于 | $ne | not equal to |
1. $gt 大于某时间
Mongo语句:
db.getCollection('abc').find({
"dt":{
"$gt":ISODate("2020-01-01T00:00:00Z")}
})
MySQL类似语句:
select dt
from abc
where dt > '2020-01-01 08:00:00'