Using painless to calculate durations

How to calculate delta value might also be useful.