BsonDateTime uploadDate = new BsonDateTime(DateTime.Now);
I thought by inserting uploadDate
as a BsonDateTime
it will store uploadDate
as type DateTime
, however that didn’t work. When I run:
db.PeopleDocument.aggregate([
{ $project: { UploadTimeType: { $type: "$UploadTime" } } }])
it returns UploadTimeType: string
.
I solved this by creating a C# console app that will delete documents created one year ago, I created a Task Scheduler that will run everyday to run this app.