AndyJ
AndyJ

Reputation: 1314

Including date or time in clocktable report

I didn't think this was going to be hard but I couldn't dig up anything on how to make an org-mode clock table report include the date/time of the task. My report is like this:

#+BEGIN: clocktable :scope agenda-with-archives  :timestamp "TIMESTAMP" :link nil :maxlevel 3  :tstart "<-1w>" :tend "<now>" :stepskip0 t :fileskip0 t :tcolumns 3 :narrow 110 :hidefiles t 
#+CAPTION: Clock summary at [2021-01-20 Wed 10:47]
   |                 |                             | <110>                                                                      |         |      |
   | File            | Timestamp                   | Headline                                                                   | Time    |      |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   |                 | ALL                         | -Total time-                                                               | -12:36- |      |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   | inbox.org       |                             | -- File time                                                               | *1:12*  |      |
   |                 |                             | Inbox                                                                      | 1:12    |      |
   |                 |                             | \_  Chat w/Saranya                                                         |         | 0:01 |
   |                 | [2021-01-20 Wed 10:45]      | \_  Troubleshoot Cylance/3503 issue                                        |         | 1:11 |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   | 01-14.org       |                             | -- File time                                                               | *1:11*  |      |
   |                 |                             | \_  MEETING: Build discussion/working session                              |         | 1:11 |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   | 01-18.org       |                             | -- File time                                                               | *1:25*  |      |
   |                 |                             | \_  MEETING: MBean registration failures in MAG DEV2 (and MAG QA2)         |         | 1:25 |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   | 01-19.org       |                             | -- File time                                                               | *1:55*  |      |
   |                 |                             | \_  MEETING: nTier Bi-Weekly - Check point                                 |         | 1:00 |
   |                 |                             | \_  MEETING: MBE Project Status Update Meeting  - Investment and MRO       |         | 0:39 |
   |                 |                             | \_  MEETING: Discuss problems encountered when installing package for 3503 |         | 0:16 |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
   | admin.org       |                             | -- File time                                                               | *0:12*  |      |
   |                 |                             | Admin                                                                      | 0:12    |      |
   |                 | <2021-01-14 Thu 09:00 ++1w> | \_  Manage timesheet                                                       |         | 0:07 |
   |                 | <2021-01-13 Wed 09:00 ++1w> | \_  Create Deploy & Environments Meeting Agenda                            |         | 0:05 |
   |-----------------+-----------------------------+----------------------------------------------------------------------------+---------+------|
...

What I'd like is to NOT have the File column and then have some type of timestamp for each task. I've tried various special properties but I can't seem to find anything that consistently gives me a timestamp.

If I have a log entry that has a recurring schedule or an inactive timestamp outside of the property drawer then it's able to pick something up. For example, in the table above the underlying tasks had entries like this:

** WIP Troubleshoot Cylance/3503 issue                                  :MBE:
   :PROPERTIES:
   :CREATED:  <2021-01-20 Wed 10:46>
   :END:
   :LOGBOOK:
   CLOCK: [2021-01-20 Wed 09:35]--[2021-01-20 Wed 10:46] =>  1:11
   :END:
   [2021-01-20 Wed 10:45] - <snip log entry>.
...
** WIP [#B] Create Deploy & Environments Meeting Agenda
   SCHEDULED: <2021-01-13 Wed 09:00 ++1w>
   :PROPERTIES:
   :LAST_REPEAT: [2021-01-06 Wed 09:35]
   :EFFORT:   0:15
   :END:
   :LOGBOOK:
   CLOCK: [2021-01-20 Wed 08:42]--[2021-01-20 Wed 08:47] =>  0:05
   <snip>
   CLOCK: [2020-07-14 Tue 16:17]--[2020-07-14 Tue 16:39] =>  0:22
   :END:

The problem is most of my tasks are either unscheduled and/or don't have timestamps outside of the logbook. I've tried various values for the :timestamp parameter but it doesn't seem to matter.

Can anyone advise how to create a clock table with task times in a column?

Another problem I have is that even with :hidefiles it always shows the File column.

Upvotes: 2

Views: 1343

Answers (1)

summea
summea

Reputation: 7583

I'm still pretty new at using clock tables in org-mode, but I came across your question when I was searching for something related to org-mode the other day.

Something that might help with displaying timestamps relates to using a setting called :properties("CLOSED"). I read about this from a post by @Fabian. When this setting is used, it adds a column named "CLOSED" that should display the date-time-stamp of when a task was "CLOSED".

Before this works, however, you might need to add the following setting to your .emacs settings file first: (setq org-log-done 'time). I read about this in the org-mode documentation. When this setting is set, and if you are using the "TODO" feature in org-mode: once you set a task to "DONE", a "CLOSED" date-time-stamp should be added to your task. From there, once you refresh your clock table, this new date-time-stamp should appear in the "CLOSED" column.

Also, from playing around with the :hidefiles settings, I ran into the same problem you had where the "File" column kept showing up even with the :hidefiles setting set. My previous attempt at fixing this (in the earlier answer revision) appears to not actually be doing what I thought it was doing, so I took that part out for now. I have the feeling that this :hidefiles setting issue might be related to the version of org-mode that is being used.

Update: After trying a more recent version of org-mode (20210201), the :hidefiles setting appears to be working as expected. I installed the new org-mode version using the setting instructions from this documentation page along with the following steps.

Warning: You may want to use an older version of org-mode depending on your needs. For myself, I tried out a very recent version of org-mode (at the time of this writing), but it might be too new for your purposes. Please consider if you need to try an older version before going through the following steps if you choose to do so.

  1. Add these lines to the .emacs file:

    (require 'package)
    (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)

  2. Open up a blank emacs editor

  3. Type: M-x list-packages

  4. Navigate to the org option (I picked the 20210201 option, but this might vary) so that the cursor is over the org link

  5. Push the return/enter key

  6. Type: C-x o

  7. Navigate to the Install option so that the cursor is over the Install link

  8. Push the return/enter key

  9. Push y to continue if you want to install this

  10. The package should install at this point

  11. When done, exit out of emacs

  12. Then, open up your .org file

Also: I added the following setting to my .emacs file, because I generally like to hide the various lists in my .org file when it first gets opened in org-mode:

; ref: https://orgmode.org/guide/Visibility-Cycling.html
(setq org-startup-folded t)

Here is an updated example of the settings I used in my example.org file (partly based on your original example):

#+BEGIN: clocktable :scope agenda-with-archives :properties("CLOSED") :maxlevel 3  :tstart "<-2w>" :tend "<now>" :timestamp t :hidefiles t
#+CAPTION: Clock summary at [2021-02-01 Mon 16:30]
| Timestamp                   | CLOSED                 | Headline                                     | Time   |      |
|-----------------------------+------------------------+----------------------------------------------+--------+------|
|                             |                        | *Total time*                                 | *1:17* |      |
|-----------------------------+------------------------+----------------------------------------------+--------+------|
|                             |                        | topic                                        | 1:17   |      |
|                             | [2021-01-29 Fri 18:22] | \_  test                                     |        | 0:01 |
| [2021-01-20 Wed 10:45]      | [2021-01-29 Fri 18:26] | \_  WIP Troubleshoot Cylance/3503 issue      |        | 1:11 |
| <2021-02-26 Fri 09:00 ++1w> |                        | \_  WIP [#B] Create Deploy & Environments... |        | 0:05 |
|-----------------------------+------------------------+----------------------------------------------+--------+------|
|-----------------------------+------------------------+----------------------------------------------+--------+------|
#+END:

* topic
** DONE test
   CLOSED: [2021-01-29 Fri 18:22]
   CLOCK: [2021-01-29 Fri 18:21]--[2021-01-29 Fri 18:22] =>  0:00
** DONE WIP Troubleshoot Cylance/3503 issue       :MBE:
   CLOSED: [2021-01-29 Fri 18:26]
   :PROPERTIES:
   :CREATED:  <2021-01-20 Wed 10:46>
   :END:
   :LOGBOOK:
   CLOCK: [2021-01-20 Wed 09:35]--[2021-01-20 Wed 10:46] =>  1:11
   :END:
   [2021-01-20 Wed 10:45] - <snip log entry>.
** TODO WIP [#B] Create Deploy & Environments Meeting Agenda
   SCHEDULED: <2021-02-26 Fri 09:00 ++1w>
   - State "DONE"       from "TODO"       [2021-01-30 Sat 10:56]
   :PROPERTIES:
   :LAST_REPEAT: [2021-01-30 Sat 10:56]
   :EFFORT:   0:15
   :END:
   :LOGBOOK:
   CLOCK: [2021-01-20 Wed 08:42]--[2021-01-20 Wed 08:47] =>  0:05
   <snip>
   CLOCK: [2020-07-14 Tue 16:17]--[2020-07-14 Tue 16:39] =>  0:22
   :END:

It's up to you if you want to take out the :timestamp t setting if adding the new "CLOSED" column.

A downside, though, with the "CLOSED" column is that I haven't found an approach that allows for scheduled tasks (that have been periodically completed) to also be shown with a date-time-stamp in the "CLOSED" column. It looks like the "SCHEDULED" setting is shown in the "Timestamp" column, but that might not be what you want.

I hope this information helps!

Upvotes: 1

Related Questions