0

I have asp net core application with MongoDB.and I'm saving the date in the format of [dd/MM/yyyy]

{"CreatedDate",DateTime.Now.Date.ToString("dd/MM/yyyy") }

whereas CreatedDate is field in the MongoDB . and i have to compare the saved date with filterDate that i'm sending. What's the best way to compare the dates with MongoDB?

Sushant Yelpale
  • 860
  • 6
  • 19
Ishwar Gagare
  • 723
  • 3
  • 9

1 Answers1

0

Do not store date object as string, you cannot compare to any date variable by this way. Yo should insert your dates like

{"CreatedDate", new Date("2017-03-24T17:00:00.832Z")} or {"CreatedDate", new Date()}
Tezcan
  • 690
  • 2
  • 6
  • 16