* Problem with date calculations in a table
@ 2008-08-14 23:48 Nick Dokos
2008-08-15 9:24 ` Chris Randle
0 siblings, 1 reply; 4+ messages in thread
From: Nick Dokos @ 2008-08-14 23:48 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Problem with date calculations in a table
2008-08-14 23:48 Problem with date calculations in a table Nick Dokos
@ 2008-08-15 9:24 ` Chris Randle
2008-08-15 11:56 ` Nick Dokos
0 siblings, 1 reply; 4+ messages in thread
From: Chris Randle @ 2008-08-15 9:24 UTC (permalink / raw)
To: emacs-orgmode
Nick Dokos wrote:
> 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 had problems getting date arithmetic to work in tables. I posted my
findings and solutions here:
http://article.gmane.org/gmane.emacs.orgmode/6536/
Don't know if it will fix your problem (too lazy to try!) but I suspect
it will.
--
Chris Randle
Org-mode 6.06b - Emacs 22.1.1 - Windows XP
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem with date calculations in a table
2008-08-15 9:24 ` Chris Randle
@ 2008-08-15 11:56 ` Nick Dokos
0 siblings, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2008-08-15 11:56 UTC (permalink / raw)
To: Chris Randle; +Cc: emacs-orgmode
Chris Randle <chris@amlog.co.uk> wrote:
> Nick Dokos wrote:
> > 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 had problems getting date arithmetic to work in tables. I posted my
> findings and solutions here:
>
> http://article.gmane.org/gmane.emacs.orgmode/6536/
>
> Don't know if it will fix your problem (too lazy to try!) but I suspect
> it will.
>
It did! I don't understand the details yet but the following seems to do
what I want:
| start | ETA (start + 12 hrs) |
|----------------------+------------------------|
| 2008-08-14 Thu 18:15 | <2008-08-15 Fri 06:15> |
| | |
#+TBLFM: $2=(date(<$1>) ? <$1>+0.5 : string(""))
The date in the first column can be just a string as above, a passive
date or an active date (the file is not in the agenda list so I don't
really have to worry about active dates).
Thanks very much,
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Problem with date calculations in a table
[not found] <20080815115807.E38CF21E5C@mailhost.cs.tu-berlin.de>
@ 2008-08-15 17:20 ` Stephan Schmitt
0 siblings, 0 replies; 4+ messages in thread
From: Stephan Schmitt @ 2008-08-15 17:20 UTC (permalink / raw)
To: emacs-orgmode, Nick Dokos
Nick Dokos wrote:
> Chris Randle wrote:
>> I had problems getting date arithmetic to work in tables. I posted my
>> findings and solutions here:
>>
>> http://article.gmane.org/gmane.emacs.orgmode/6536/
>>
>> Don't know if it will fix your problem (too lazy to try!) but I suspect
>> it will.
>>
> It did! I don't understand the details yet but the following seems to do
> what I want:
>
> | start | ETA (start + 12 hrs) |
> |----------------------+------------------------|
> | 2008-08-14 Thu 18:15 | <2008-08-15 Fri 06:15> |
> | | |
>
> #+TBLFM: $2=(date(<$1>) ? <$1>+0.5 : string(""))
>
> The date in the first column can be just a string as above, a passive
> date or an active date (the file is not in the agenda list so I don't
> really have to worry about active dates).
>
> Thanks very much,
> Nick
>
>
Hi,
I tried it, too, but got the same time (6:15) when adding
1.0 or 2.0.
how bizarre!
| start | ETA (start + 48 hrs) |
|----------------------+------------------------|
| 2008-08-14 Thu 18:15 | <2008-08-16 Sat 06:15> |
| | |
#+TBLFM: $2=(date(<$1>) ? <$1>+2.0 : string(""))
Greetings,
Stephan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-08-15 17:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-14 23:48 Problem with date calculations in a table Nick Dokos
2008-08-15 9:24 ` Chris Randle
2008-08-15 11:56 ` Nick Dokos
[not found] <20080815115807.E38CF21E5C@mailhost.cs.tu-berlin.de>
2008-08-15 17:20 ` Stephan Schmitt
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.