0

Emacs 26.1

|   | Start date             | End date               | State | Task     | Duration (hours) |
|---+------------------------+------------------------+-------+----------+------------------|
| # | <2018-01-02 Wed 10:30> | <2018-01-02 Tue 14:00> | Taken | some url |         00:00:00 |
| # | <2018-01-02 Wed 14:00> | <2018-01-02 Wed 18:00> | Taken | some url |         00:00:00 |
| # | <2018-01-03 Wed 10:00> | <2018-01-03 Wed 12:00> | Taken | some url |         00:00:00 |
| # | <2018-01-03 Wed 14:00> | <2018-01-03 Wed 18:00> | Taken | some url |         00:00:00 |
|---+------------------------+------------------------+-------+----------+------------------|
|   |                        |                        |       |          |         00:00:00 |

#+TBLFM: $6=60*60*24*date(<$3>)-date(<$2>);T :: @>$6 = vsum(@I..@II);T

But as you can see the last column (Duration) not calculate.

Why?

1

The t, T, and U flags expect an input value in the format HH:MM:SS, not a time stamp. Time stamps are an org-mode invention, so org-mode knows how to deal with them without any special flags. Also, you can't have a space between the bottom of your table and the #TBLFM: directive. Finally, if you want to convert a value in days to a value in hours, you only need to multiply it by 24, not by 24*60*60 (which converts days to seconds).

Taken together, I think what you need is:

|   | Start date             | End date               | State | Task     | Duration (hours) |
|---+------------------------+------------------------+-------+----------+------------------|
| # | <2018-01-02 Wed 10:30> | <2018-01-02 Tue 14:00> | Taken | some url |         3.499992 |
| # | <2018-01-02 Wed 14:00> | <2018-01-02 Wed 18:00> | Taken | some url |         4.000008 |
| # | <2018-01-03 Wed 10:00> | <2018-01-03 Wed 12:00> | Taken | some url |         1.999992 |
| # | <2018-01-03 Wed 14:00> | <2018-01-03 Wed 18:00> | Taken | some url |         4.000008 |
|---+------------------------+------------------------+-------+----------+------------------|
|   |                        |                        |       |          |             13.5 |
#+TBLFM: $6=24 * ($3-$2) :: @>$6 = vsum(@I..@II)
  • I was also thinking about it. I came up with '$6=time($3-$2)' do you have an idea how to show the result as 'HH:MM:SS'? – jue Jan 16 at 19:27
  • @jue from calc the format of HMS output is controlled by the function calc-hms-notation. I'm not sure how to apply that to an org-table – Tyler Jan 16 at 20:43
  • @jue see emacs.stackexchange.com/questions/46859/… – Tyler Jan 16 at 20:46
  • @Tyler I need to show duration in format HH:MM:SS – a_subscriber Jan 17 at 8:48
  • you asked why your formula wasn't getting calculated, that's what I answered. you have asked how to get HH:MM:SS in another question, and that question has two good answers already: emacs.stackexchange.com/questions/46859/… – Tyler Jan 17 at 12:53

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.