1

Consider the following org-table, where the first 3 columns are inputs:

|----------+-------+-------+----------+------+--------|
|     Date | Start |   End | H. slept |      |  Delta |
|----------+-------+-------+----------+------+--------|
| 20230727 |  3:30 |  8:30 |    05:00 | 8:00 | -03:00 |
| 20230728 |  1:00 |  8:30 |    07:30 | 8:00 | -00:30 |
| 20230729 |  1:00 |  9:00 |    08:00 | 8:00 |  00:00 |
| 20230730 |  0:00 |  9:00 |    09:00 | 8:00 |  01:00 |
| 20230731 |  1:45 |  8:50 |    07:05 | 8:00 | -00:55 |
|----------+-------+-------+----------+------+--------|
|     Mean | 01:27 | 08:46 |    07:19 |      | -03:25 |
|----------+-------+-------+----------+------+--------|
#+TBLFM: $4=$3-$2;U::$6=$4-$5;U::@7$2=vmean(@II..@III);U::@7$3=vmean(@II..@III);U::@7$4=vmean(@II..@III);U::@7$6=vsum(@II..@III);U

I would like to delete $5, and put the 8 hours directly in $6 formula instead. How could I do that to produce the same results?

crocefisso
  • 1,141
  • 7
  • 15
  • I guess [HMS-Formats](https://www.gnu.org/software/emacs/manual/html_mono/calc.html#HMS-Formats) is supposed to provide an explanation on how to do that. But unfortunately, I'm not able to understand it (too cryptic for me)... – crocefisso Jul 31 '23 at 07:13
  • 1
    You can shorten the `#+TBLFM` line by using a [range](https://orgmode.org/manual/Field-and-range-formulas.html) on the LHS: `#+TBLFM: $4=$3-$2;U::$6=$4-$5;U::@7$2..@7$4=vmean(@II..@III);U::@7$6=vsum(@II..@III);U`. And instead of `@7`, it's probably better to use `@>` ("the last row" - see [References](https://orgmode.org/manual/References.html)). – NickD Jul 31 '23 at 16:23
  • Thank you @NickD, I didn't know about `@7$2..@7$4=`. However, I find its use problematic since it is incompatible with doing `C-u C-=` on cells. – crocefisso Aug 04 '23 at 06:31

1 Answers1

2

You can add or subtract seconds to a calc time.

So your formula for column 6 can be:

$6=$4-(8*3600)
Juancho
  • 5,395
  • 15
  • 20