MongoDb Query using C# for date time -
i working on mongodb using c# drivers. want query mongodb database find out row has eventdate greater 13 months todays date.
my mongodb has structure similar below:
eventdate of datatype : datetime
{ "_id" : objectid("525239e3e9374f1c3ce4123b"), "rowid" : 41133552, "eventdate" : isodate("2013-08-19t00:00:28z"), "product" : "supporttool", "language" : "en", "guid" : "67cd73d4-36bc-4c9f-9a4c-144b38d4e928", }
please can me out mongocollection data event date older 13 months.
there's more 1 way it, 1 linq extension method syntax:
mongodatabase db = yourmongodatabaseobject; var cursor = db.getcollection<yourclass>("yourclass").find( query<yourclass>.lt(p => p.eventdate, datetime.utcnow.addmonths(-13));
this return cursor documents in "yourclass"
collection have an eventdate
less 13 months ago , deserialize them instances of yourclass
.
Comments
Post a Comment