If I understand the question correctly, you need the difference between the two dates in your date field. Can you please let us know why you are trying to do this? Based on the document you provided, you can try the $dateDiff which would return the difference between the two dates. To select elements from the array, you can use $arrayElemAt which returns the element at the specified array index.
This is what the query would look like, there are other fields in $dateDiff too that you can use according to your use case. Also, note the use of arrayElemAt indexes as 0 (the first element) and -1 (the last element), you can adjust the indexes as per your data:
Thank you a lot @Satyam! The thing is that the date array can have more than 2 elements, and if so, I’d like to know the date difference between each index and the current one. In the case you mentioned, it’s always the first and the last one