I have a table containing Date, Waketime and Sleeptime as dates. Based on these data, I want to calculate the duration of sleep the night before. Below you can see an example of a table that I would like to get:
| Date | Waketime | Bedtime | Sleep |
| <2012-09-24 Mon> | 6:00 | 22:00 | |
| <2012-09-25 Tue> | 8:00 | 01:00 | 10:00 |
| <2012-09-26 Wed> | 7:00 | 23:00 | 6:00 |
When I apply the table formula:, #+TBLFM: $4=if((24-$3)<12, (24-$3)+@-1$2, $3+@-1$2);tthis does not give the desired result due to the fact that integers (24, 12 ...) are interpreted as seconds.
Invalid result:
| Date | Waketime | Bedtime | Sleep |
| <2012-09-24 Mon> | 6:00 | 22:00 | |
| <2012-09-25 Tue> | 8:00 | 01:00 | 5.01 |
| <2012-09-26 Wed> | 7:00 | 23:00 | -14.99 |
How can I adjust this formula so that it returns the correct duration of sleep?
, if, -, Sleeptime. 12 , Bedtime Waketime. 12 , 24 Bedtime Waketime