Database
[{id:1,name:"a",offer:true,expiryDate:"23-03-2022"},{id:2,name:"b",offer:false},{id:3,name:"c",offer:true,expiryDate:"01-01-2021"},{id:4,name:"d",offer:true,expiryDate:"01-06-2022"}]
Query
db.collection.aggregate([{"$match":{}},{"$set":{"offer":{"$cond":{"if":{"$lt":[{"$toDate":"$expiryDate"},"$$NOW"]},"then":false,"else":true}},"expiryDate":{"$toDate":"$expiryDate"}}},{"$sort":{"expiryDate":-1,"offer":-1}}])