I use org-mode to do time registration. Is there a way to round time register using clock-in / clock-out up to a multiple of a user defined value for instance 5 mins when generating a org-clock-table report?
I had to do something similar at work and I solved it by calling the clocktable with a (calc) formula:
#+BEGIN: clocktable :maxlevel 3 :block 2017-10-24 :formula "$2=$3;t::$3=if($2 == 0, string(\"\"), round(100*ceil($2*12)/12)/100)" #+END:
- Depending on your use of levels (
maxlevels) you might need to change the column numbers.
- I usually create a clocktable per day.
:block 2017-10-24would be for today.
- Since the clocktable usually contains the clocked time in the format
0:00which is not as easy to calculate with, I use the
tflag to display the values in decimal numbers. This requires
org-table-duration-custom-formatto be set to the default
- Then I use some calc formulas:
ceilis used to round up to the next full 5 minutes. If you prefer to go to the nearest 5 minute unit (round up or down), you can replace it with
round. The outer formula (
round) is then used that the result has only two decimals digits.
- I use the
ifclause to check if the result is 0.00 or not. If it is, which means there is no clocked time (in my case on the headers), the cell should be empty.
I finally had the chance to try this out and it does not work as intended. For a table with :maxlevel 5 what would the the #+BEGIN line have to look like?– macNov 26, 2017 at 1:25
I am sorry to hear that. So, you're working with
maxlevel 5. The time numbers you want to round are therefore all in the 5th column or are there other times you want to round (and in which column)? In the former case try it with this formula:
:formula "$6=5;t::$7=if($6 == 0, string(\"\"), round(100*ceil($6*12)/12)/100)". This should create a new 6th column in which the numbers from the 5th column are converted to decimals and a new 7th column where the rounding happens.– FabianNov 27, 2017 at 5:58
The numbers that need to be rounded are in all cols expect the total. Problem is that numbers in col 4 are already the addition of col 5 and col 4. I think I need to format the initial clock-table differently to achieve what I want, but I don't know how.– macNov 27, 2017 at 9:46
How about you use a different
maxlevel(e.g. 3 like in my answer)? This already formats the clock-table differently. Or how about you give me an (anonymized) example of how your clock-table looks like before any formula was applied to it and tell me which numbers you would like to be rounded.– FabianDec 30, 2017 at 10:22