Command aggregate failed: Remote error from mongot :: caused by :: \"origin\" must be a date, number, or geoPoint (from \"compound.should[1].near\")

Using C# how can I give current date in origin of near object in search stage. I’ve already tried DateTime.Now & new Date() but it always throw error on aggregation.

Here is the my complete question:

could you try to use

new BsonDateTime(origin) to convert the date to a BsonDataTime.

@Marcus Thanks for you response.

I’ve tried what you’ve told me but still it is throwing same error.

You can see my code

var nearCreateDateObject = new NearClauseSearchModel
{
path = “CreatedDate”,
origin = new BsonDateTime(DateTime.Today.Date),
pivot = Convert.ToUInt64(“7776000000”),
score = GenericObject(“boost”, GenericObject(“value”, createDateScore))
};

and this is the final bson.
“near”:{
“path”:“CreatedDate”,
“origin”:“2021-04-17T19:00:00Z”,
“pivot”:“NumberLong(”“7776000000"”)",
“score”:{
“boost”:{
“value”:1
}
}
}