I am trying to add a custom field to calculate the hour difference between current utc time and a date field in my collection. However, I am unable to specify the right expression. Given that there is a field called EventTime, I am trying to do this:
{
$divide: [
{
$subtract: [
new Date(),
"$EventTime"
]
},
1000 * 60 * 60
]
}
`
However, I keep getting this error:
`(TypeMismatch) Executor error during getMore :: caused by :: can't $subtract date from string, correlationID = 17b5aa0a81597aa7ed3893a3`