Welcome to the MongoDB Community Forums!
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:
Please let us know if you have any further questions. Feel free to reach out for anything else as well.