SOLVED

Calculate Difference on Time

Copper Contributor

Hi All,

 

Is there a way to calculate difference between 2 times to show for example how many days between the first and second value?

 

The image below provides the results and ideally I'd have another column that calculated that difference, just not sure what the operator would be to calculate that (can always remove the time portion to just get how many days it is).

 

Time Results.png

2 Replies
best response confirmed by SH30 (Copper Contributor)
Solution

You could try this approach:

 

datatable (Date1:datetime, Date2:datetime)
[
datetime(2018-06-11 10:05:00), datetime(2018-06-11 11:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-12 11:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-13 14:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-15 09:05:00)
]
| project Diff=format_timespan(Date2-Date1,"d"), Date1, Date2
 

Exactly what I was looking for, much appreciated!

1 best response

Accepted Solutions
best response confirmed by SH30 (Copper Contributor)
Solution

You could try this approach:

 

datatable (Date1:datetime, Date2:datetime)
[
datetime(2018-06-11 10:05:00), datetime(2018-06-11 11:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-12 11:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-13 14:05:00),
datetime(2018-06-11 10:05:00), datetime(2018-06-15 09:05:00)
]
| project Diff=format_timespan(Date2-Date1,"d"), Date1, Date2
 

View solution in original post