Can I calculate the time elapsed between two date macros?
Asked by Matthias:

Hello, I am currently setting up a page property report for an overview page that tracks individual jobs our team is working on. The columns are client, assignee, begin date + end date (as macros) etc.

Our team leader would now like to track the individual time any job lasts in a seperate column entitled "duration". In order to avoid manual calculation I would like to automate this task by calculating the delta between the begin date macro and the end date macro.

The result should show up as "5 days" or similar in a seperate column.

NB our jobs typically run uninterrupted for several days also over weekends, so there is no need to differentiate between business days and days off.

Thank you!

Matthias


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hello Matthias,

This use case can be resolved with the help of the [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence) app.  
You can wrap your Pape Properties Report with the [Table Transformer](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Transformer+macro) macro and enter the following [SQL](https://docs.stiltsoft.com/display/public/TFAC/List+of+SQL+functions+available) query:  
SELECT \*, DATEDIFF(day,'Begin date','End date')+ " days" as 'Duration' from T1  

![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/88770i044AD1A34BE1E661/image-size/large?v=v2&px=999 "1.png")![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/88771iEE01932206912C71/image-size/large?v=v2&px=999 "4.png")  

![5.png](https://community.atlassian.com/t5/image/serverpage/image-id/88769i71BAAE9C2BE61DC8/image-size/large?v=v2&px=999 "5.png")

Please find our [documentation](https://docs.stiltsoft.com/pages/releaseview.action?pageId=42239760) to get more info how to use our app.

Best regards,  
Katerina  
StiltSoft

comments: author: Matthias
body: Hello Katerina,

thank you so much for your answer, it worked out just fine. There are only two minor issues, hope you can help me with these as well:

1) The "Duration" now shows up in in decimal number days (14,9999999 days) instead of rounded integers (15 days) - can you tell me where to change this?

2) I also have Table Filter included to make it easier browse the files, my current page architecture looks like this:

![2020-04 Confluence msr.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/88934iC2D823F15CB99A61/image-size/large?v=v2&px=999 "2020-04 Confluence msr.PNG")Problem is that the report filter to help browse the page now appears BELOW the list, the team would prefer to have it on top of the list (specifically once we have several hundred entries it would be very clumsy to scroll all the way down to the list to start a filter search.

Maybe you can help there as well. Other than that, thanks for the quick reply here!

Matthias


author: Katerina Rudkovskaya [Stiltsoft]
body: Hello Matthias,

Let's try to replace that SQL query for the following:  
SELECT \*, ROUND(DATEDIFF(day,'Begin date','End date'))+ " days" as 'Duration' from T1

![6.png](https://community.atlassian.com/t5/image/serverpage/image-id/88947i169DCFBD149AE0D1/image-size/large?v=v2&px=999 "6.png")

<br />

Regarding the second question, you need to wrap the Page Properties Report macro with Table Transformer at first and then add Table Filter.

Best regards,  
Katerina  
StiltSoft


author: Matthias
body: Excellent Katerina, all works fine now.

Thank you and stay safe!

Matthias


author: Katerina Rudkovskaya [Stiltsoft]
body: You're welcome, Matthias :)  
Thanks, you too!   

Katerina   
StiltSoft


Tags: macro