3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MongoDBのコンソールから日付で検索

Posted at

個人的なメモ。

// collectionNameは対象のコレクション(テーブル)名に置き換える
db.collectionName.count() //=> 50   レコード数が返る
col = db.collectionName
col.find({ "date" : { "$gte" : ISODate("2015-05-08T00:00:00Z")}})
//"date"フィールドが2015年5月8日以降のものを検索する

$gteは「>=」のこと。
$gt、$lt、$lteはそれぞれ「>」「<」「<=」に対応する。
$gteと$lteを一緒に指定すれば「X日〜Y日まで」という指定も可能。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?