confluenceconfluence-macros

How do I calculate duration between the dates in Confluence


I am trying to display duration column with difference between 2 dates in Confluence. I have tried below:

select *,(CAST(ROUND(ceiling(DATEDIFF(DAY,'From Date','To Date')))as int))+1+ " days" as 'Duration' from T1

this gives the result, however given the dates 25-Jun-2020 to 26-Jun-2020 - duration displayed as 1 instead of 2.

your help is appreciated here. thanks.


Solution

  • select *,('To Date' - 'From Date' + "24h") / "24h" + " days" as 'Duration' from T1

    this works perfectly with below settings in confluence

    365 days in a year 7 days a week 24 hours in a day dd.mm.yy points,