Time formatting for org clocktable report

Viewed 784

I use org-clock table to track time. It is more convenient for me to see time in hours, not in days. How could I configure org clocktable to do that?

Here is what I get now:

* A
  :LOGBOOK:
  CLOCK: [2020-05-08 Fri 10:37]--[2020-05-08 Fri 23:37] => 13:00
  CLOCK: [2020-05-07 Thu 13:37]--[2020-05-07 Thu 23:37] => 10:00
  :END:
* D
  :LOGBOOK:
  CLOCK: [2020-05-08 Fri 03:37]--[2020-05-08 Fri 05:37] =>  2:00
  CLOCK: [2020-05-06 Thu 03:37]--[2020-05-06 Thu 05:37] =>  2:00
  :END:


#+BEGIN: clocktable :scope file :maxlevel 2
#+CAPTION: Clock summary at [2020-05-08 Fri 19:40]
| Headline     |      Time |
|--------------+-----------|
| *Total time* | *1d 3:00* |
|--------------+-----------|
| A            |     23:00 |
| D            |      4:00 |
#+END:

Note "Total time" is "1d 3:00". I want total time to be shown as 27:00.

1 Answers

The time format is controller by the variable org-duration-format which has a very long description (C-h v org-duration-format RET). I quote selectively here:

The value can be set to, respectively, the symbols ‘h:mm:ss’ or ‘h:mm’, which means a duration is expressed as, respectively, a "H:MM:SS" or "H:MM" string.

So adding this to the file:

#+begin_src emacs-lisp
(setq org-duration-format 'h:mm)
#+end_src

and evaluating it with C-c C-c will allow the clocktable to look like this:

#+BEGIN: clocktable :scope file :maxlevel 2
#+CAPTION: Clock summary at [2020-05-11 Mon 22:10]
| Headline     |    Time |
|--------------+---------|
| *Total time* | *27:00* |
|--------------+---------|
| A            |   23:00 |
| D            |    4:00 |
#+END:

You can also of course customize the variable if you want to avoid code.

Also, if you don't like the asterisks, you can customize the variable org-clock-total-time-cell-format whose default value is the string *%s*.

Related