It would be really nice to have a flexible date difference operator that calculates the difference between two dates resulting in a duration (e.g. duration in msecs, secs, mins, hours, etc).
Consider the following projection stage in an aggregation pipeline. I need to calculate the difference in days between two dates - and one date may be null.
This works - and it's fast - but it would be more pleasant if I could specify something like:
ArangoDB offers a date difference function which is pretty nice,
DATE_DIFF(date1, date2, unit, asFloat): Calculate the difference between two dates in given time unit, optionally with decimal places. Returns a negative value if date1 is greater than / after date2.
unit can be either of the following to specify the time unit to return the difference in (case- insensitive):
y, year, years
m, month, months
w, week, weeks
d, day, days
h, hour, hours
i, minute, minutes
s, second, seconds
f, millisecond, milliseconds