SOLVED

Calculate a duration in column formatting

Iron Contributor

How can I calculate a duration in column formatting?

 

With calculated columns, I can calculate a duration in days by subtracting two dates. For example if Start is 9/2/2018 and End is 1/31/2019, End-Start returns 151.

 

With column formatting, End-Start returns 5/31/1970.

 

I understand that I could use both the calculated column and column formatting, but I'd rather do it in one shot. My formatting involves multiple calculations.

1 Reply
best response confirmed by Christophe Humbert (Iron Contributor)
Solution

I found a solution with the help of another thread.

 

The Number() operator converts a date into millisaconds. So the formula I came up with in column formatting is:

"=(Number([$End])-Number([$Start]))/1000/60/60/24"

1 best response

Accepted Solutions
best response confirmed by Christophe Humbert (Iron Contributor)
Solution

I found a solution with the help of another thread.

 

The Number() operator converts a date into millisaconds. So the formula I came up with in column formatting is:

"=(Number([$End])-Number([$Start]))/1000/60/60/24"

View solution in original post