Home > Blockchain >  Mongodb filter out Date() and ISODate() from same field
Mongodb filter out Date() and ISODate() from same field

Time:06-25

This is my schema for the date field

startDate: {type: Date, default: Date.now},

Somehow this field have 2 different value like this

Date(29906992800000) and ISODate("2022-05-31T03:23:32.193-06:30")

Now I am trying to filter out Date(...) to convert to ISODate(...). Is there any way to query such values? Conversion I can handle it through node application.

First

db.<collection>.find({_id:<id>}, {_id:0, <field>:1})

returns

{"startDate": Date("29906992800000") }

Second

db.<collection>.aggregate([{$match:{_id:<id>}, {$project:{_id:0, t:{$type:"<field>"}}}}])

returns

{"t": "string"}

CodePudding user response:

Thank you @Alex I am posting as answer.

We have imported the data to MongoDB Compass, and used the normal sort method to filter out these dates and updated manually. Before I used Robo 3T may be that have some limitations.

enter image description here

  • Related