1

I have a collection and I need to extract only most recent data based on field updateDate (with data type Date). I use c++ driver (mongocxx (v3) ).

mongocxx::cursor cursor = 
    collection.find(document{} << "updateDate" << 
                    open_document << "$gt" << 
                    (date parameter)  << close_document <<
                    finalize); 

for(auto doc : cursor) { 
    std::cout << bsoncxx::to_json(doc) << "\n"; 
}

How can I write my query for instance: what format, data type I need to pass as day?

Thank you.

erip
  • 16,374
  • 11
  • 66
  • 121
andre9875
  • 31
  • 4
  • Possible duplicate of [MongoDB C++, How to add ISODate value when inserting](http://stackoverflow.com/questions/40797650/mongodb-c-how-to-add-isodate-value-when-inserting) – styvane Nov 25 '16 at 06:05

1 Answers1

1

You can do something like this :

replace (date parameter) with bsoncxx::types::b_date{<value>}

satish chennupati
  • 2,602
  • 1
  • 18
  • 27