How to format dates for $gte

Hi all

I am trying to work on the ‘Lab - bringing it all together’ and can’t figure out how to get the below syntax working to find the movies release after 1990:

{released: {$gt: “1990-01-01” }}

Hi @Nishant_53812,

Please check the documents in the aggregations.movies collection. You can compare the year field to get all the movies released in 1990 or after.

Please feel free to reach out if you have any questions.

Thanks,
Sonali

When you compare a object whose type is ISO Date.
For example, search the registres which year is 1990 or after .

db.movies.aggregate([{$match:{"released":ISODate($gte: ISODate("1990-01-01"))]).pretty()

It is the same syntax as the rest.

"field_name" : { "$gte" : ISODate("1990-01-01") }

Be aware of

1 Like