As you request by date and date in Mongo

Will it be the equivalent of this SQL statement?

Select * from example WHERE date = '2011-09-21' 

The record is stored in the MongoDate field.

I would also like to know the syntax between requests.

+8
php mongodb
source share
1 answer

Will it be the equivalent of this SQL statement?

Select * from the example WHERE date = '2011-09-21'

 db.example.find({date: dateobject}); 

In the case of MongoDB + PHP, you want to use the [MongoDate][2] class to represent these dates. Other language drivers typically use a language date construct.

I would also like to know the syntax between the request.

MongoDB does not have a between clause.

To use More, you will need to use one of the query operators. See here for more details. A simple example:

 db.example.find({ date: { $gt: lowdate, $lt: highdate } }); 
+8
source share

All Articles