Database

[{date:[{"updatedAt":"2020-10-01T12:12:12Z"},{"updatedAt":"2020-10-01T12:12:12Z"},{"updatedAt":"2020-10-01T12:12:12Z"},{"updatedAt":null},{"updatedAt":"2020-10-01T12:12:12Z"}]}]

Query

db.collection.aggregate([{$project:{a:{$size:{$filter:{input:{$slice:["$date",1,{$subtract:[{$size:"$date"},2]}]},cond:{$ne:["$$this.updatedAt",null]}}}}}}])

Result