Forum Discussion
pho30
Jun 13, 2018Copper Contributor
Calculate Difference on Time
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).
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
2 Replies
- Emilian ErtelBrass Contributor
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- pho30Copper Contributor
Exactly what I was looking for, much appreciated!