5

org-clock-report is awesome; however, it reports time spent on each task. Is there any custom command that you use to generate a clock report showing hours worked, across tasks, for each day?

The trouble I've encountered is that, I file my TODO captures under a file+datetree entry. For example, one TODO task might be filed on Day -2, but I could be working on it -- i.e., clocking in and out -- on Day -2, -1, and today. So generating a table naively will just show something like:

#+BEGIN: clocktable :maxlevel 4 :scope file :block thisweek 
#+CAPTION: Clock summary at [2017-09-23 Sat 11:48], for week 2017-W38.
| Headline                              | Time      |         |       |       |
|---------------------------------------+-----------+---------+-------+-------|
| *Total time*                          | *1d 0:12* |         |       |       |
|---------------------------------------+-----------+---------+-------+-------|
| 2017                                  | 1d 0:12   |         |       |       |
| \_  2017-09 September                 |           | 1d 0:12 |       |       |
| \_    2017-09-11 Monday               |           |         |  1:23 |       |
| \_      look into AAA BBBB project    |           |         |       |  
| \_    2017-09-15 Friday               |           |         |  3:33 |       |
| \_      look into XXX YYYY project    |           |         |       |  3:33 |
#+END:

Note that the second TODO task was filed under 2017-09-15 Friday, which was the date I entered the task. But really, I might have worked on it on Friday, Saturday, etc. I just want another command to show how many hours I've worked on each day, generating a report such as the following:

2017-09-11 Monday     xx hours yy mins worked (across all tasks)
...
2017-09-15 Friday     zz hours tt mins worked (across all tasks)

Thanks in advance.

  • Side question: does this use case illustrate that I should not file TODO tasks under a datetree? – Covi Sep 23 '17 at 19:04
6

I think you might consider this to be a partial solution to your question.

If you include :step day in your clocktable line then you'll get several clock tables emitted -- one per day for the current week in your example.

While this answers the first part of your question of showing what tasks were worked on per day, you'll still see those tasks under a hierarchy based on your datetree structure of when you created those tasks. If you also include maxlevel 0 in the clocktable then you'll only see the total for each day without any tasks listed, which I think gets you the data you asked for although not quite in the simple list-format you wanted.

Link to the appropriate bit of the manual: http://orgmode.org/manual/The-clock-table.html

The second part of the question about whether TODO tasks are a good fit for a datetree structure is, I think, down to personal choice. On the one hand it makes it easy to locate tasks in a large file according to when it was added (although I suspect you could do the same thing with a custom agenda view), but on the other hand it prevents you grouping tasks into hierarchies for larger-scale projects. Choosing between those options depends on how you want to use org-mode.

My personal choice would be that datetrees are good for "journal"-type entries (e.g. notes on what was done each day), but with tasks filed in a project hierarchy, but there's no single right way.

  • 2
    Thank you! #+BEGIN: clocktable :maxlevel 0 :scope file :step day :tstart "<-1w>" :tend "<now>" :compact t seems to work well and gives the desired format. Following up: is there an easy way to bind this to some keys, so that I can easily pop such a table out anywhere in any org file? Currently I have to put this in a fixed file, fixed position, then C-c C-x C-r to update it. – Covi Sep 27 '17 at 17:55
  • 1
    @Covi. Glad that helped. Sorry for the slow response time. While you could write an interactive function and bind that to a key to do that, as it's all text why not record the process as a keyboard macro (type in the clocktable begin/end lines, move up, do C-c C-c to recalc it), then save that macro as a new function (which you could put in your init.el)? Relevant links: emacswiki.org/emacs/KeyboardMacrosTricks and gnu.org/software/emacs/manual/html_node/emacs/… – Stuart Hickinbottom Nov 16 '17 at 8:03
  • Is there a way to start a report always on a certain weekday such as Monday? eg. If I'm in the middle of this week and I set :tstart "<-2w>", it shows me the last few days of the week before last as well while I just want to see the last week and this week. Something similar to org-agenda-start-on-weekday? – kshenoy Jul 19 '18 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.