From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Problem with date calculations in a table Date: Thu, 14 Aug 2008 19:48:12 -0400 Message-ID: <17380.1218757692@alphaville.usa.hp.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTmZY-0006hL-9Z for emacs-orgmode@gnu.org; Thu, 14 Aug 2008 19:49:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTmZW-0006gZ-PQ for emacs-orgmode@gnu.org; Thu, 14 Aug 2008 19:49:40 -0400 Received: from [199.232.76.173] (port=48037 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTmZW-0006gL-Ic for emacs-orgmode@gnu.org; Thu, 14 Aug 2008 19:49:38 -0400 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:5880) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KTmZV-0002SZ-KV for emacs-orgmode@gnu.org; Thu, 14 Aug 2008 19:49:37 -0400 Received: from smtp2.fc.hp.com (smtp.fc.hp.com [15.11.136.114]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id 5D69CC6B8 for ; Thu, 14 Aug 2008 23:48:04 +0000 (UTC) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I've been trying to make a table with the following structure: column 1 contains either a date or is empty; column 2 contains a date that's calculated from the corresponding date in column 1 (if column 1 contains a date) or is empty (if column 1 is empty). In the example below, column 2 is supposed to be the date 12 hours or 0.5 days after the date in column 1 (assuming that it is non-empty). I have tried various formulas as shown in the tables below where row 1 contains a date in column 1 and row 2 is supposed to be empty: | start | ETA (start + 12 hrs) | |------------------------+----------------------------| | <2008-08-14 Thu 18:15> | <2008-08-15 Fri 06:15> | | | <+1-01-01 Sat> ? 0 + 0.5 : | #+TBLFM: $2=(date($1)?$1+0.5:string("")) | start | ETA (start + 12 hrs) | |------------------------+---------------------------------------------------------| | <2008-08-14 Thu 18:15> | <2008-08-14 Thu 06:15> ? <2008-08-14 Thu 06:15> + 0.5 : | | | | #+TBLFM: $2=($1?$1+0.5:string("")) | start | ETA (start + 12 hrs) | |------------------------+--------------------------------------------------------------| | <2008-08-14 Thu 18:15> | 733269.76 != <+1-01-01 Sat> ? <2008-08-14 Thu 06:15> + 0.5 : | | | | #+TBLFM: $2=(date($1)!=date(0)?$1+0.5:string("")) | start | ETA (start + 12 hrs) | |------------------------+---------------------------------| | <2008-08-14 Thu 18:15> | <2008-08-15 Fri 06:15> | | | <+1-01-01 Sat> != 0 ? 0 + 0.5 : | #+TBLFM: $2=(date($1)!=date(<+1-01-01 Sat>)?$1+0.5:string("")) but as you can see, there is no formula that gets both rows right. This is a subset of all the trials that I have done: none seems to work. I'm almost certain that the error (if it is indeed an error and not my own stupidity) lies with calc-eval, not with org-table, but I am just not ready to wade into those waters yet. If somebody has a different formula, a work-around for any of the above or some related formula, or can give me the proper head-whack to point me in the right direction, I'd appreciate it very much. BTW, I tried the if(a,b,c) form of the conditional as well, but it does not make any difference afaict: they seem to be entirely equivalent. That's what I would have expected, but desperate situations call for desperate measures!-) Thanks, Nick Version info: Linux 2.6.24-19-generic #1 SMP Fri Jul 11 23:41:49 UTC 2008 i686 GNU/Linux GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.9) of 2008-07-01 Org-mode version 6.06b