Search code examples
datetimeemacsspreadsheetorg-modeorg-table

Calculating Duration in org mode table


I'm trying to figure out how to to use org-mode to calculate the duration between two time points, however, whilst I figured out how to do it for two separate dates, when I add in the time component, it gives an answer, but I'd rather have the answer in

XX days, xx hours, xx minutes

 | Start                  | End                    | Duration |
 |------------------------+------------------------+----------|
 | <2013-07-16 Tue 15:15> | <2013-07-17 Wed 11:15> | 0.833333 |
 |                        |                        |        0 |
   #+TBLFM: $3=(date(<$2>)-date(<$1>))

Solution

  • You may use the T flag to use the form HH:MM[:SS]. Example:

    | Start                  | End                    |     Days | HH:MM:SS |
    |------------------------+------------------------+----------+----------|
    | <2013-07-15 Tue 10:15> | <2013-07-17 Wed 11:15> | 2.041667 | 49:00:00 |
    |                        |                        |        0 | 00:00:00 |
    
    #+TBLFM: $3=date(<$2>)-date(<$1>)::$4=60*60*24*$3;T