This would be the equivalent of this SQL statement?
Select * from example WHERE date = '2011-09-21'
The record is stored with a MongoDate field.
I would also like to know the syntax of the between query.
This would be the equivalent of this SQL statement?
Select * from example WHERE date = '2011-09-21'
db.example.find({date: dateobject});
In the case of MongoDB + PHP, you'll want to use the [MongoDate][2]
class to represent those dates. Other language drivers typically just use the language date construct.
I would also like to know the syntax of the between query.
MongoDB does not have a between
clause.
To use "Greater than" you will need to use one of the query operators. See here for details. Simple example:
db.example.find({ date: { $gt: lowdate, $lt: highdate } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With