From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: dates in a spreadsheet Date: Thu, 18 Mar 2010 20:31:19 +0000 Message-ID: <87aau5tlrc.wl%ucecesf@ucl.ac.uk> References: <3a257d511003162304o7eea96b4u40c581bb3bd69521@mail.gmail.com> <87eijjynnm.fsf@stats.ox.ac.uk> <3a257d511003170951q342b2165vdcc51391c4277911@mail.gmail.com> Reply-To: Eric S Fraga Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsMNT-00034f-Ck for emacs-orgmode@gnu.org; Thu, 18 Mar 2010 16:31:35 -0400 Received: from [140.186.70.92] (port=57492 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsMNR-00031Y-Oo for emacs-orgmode@gnu.org; Thu, 18 Mar 2010 16:31:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NsMNP-0002zX-Sk for emacs-orgmode@gnu.org; Thu, 18 Mar 2010 16:31:33 -0400 Received: from vscane-c.ucl.ac.uk ([144.82.108.43]:37768) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NsMNP-0002yr-OU for emacs-orgmode@gnu.org; Thu, 18 Mar 2010 16:31:31 -0400 In-Reply-To: <3a257d511003170951q342b2165vdcc51391c4277911@mail.gmail.com> 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: Josh Mattoon Cc: Dan Davison , emacs-orgmode@gnu.org On Wed, 17 Mar 2010 09:51:04 -0700, Josh Mattoon wrote: > > [1 ] > [1.1 ] > Sure thing. Basically I'd like the "date" column to be automatically > calculated so that I can move things around, add extra days here and there, > and not have to edit that column by hand. > > | date | location | activities | notes | > |-----------+----------+---------------+----------------------------| > | 03-16 Tue | moon | collect rocks | | > | 03-17 Wed | mars | terraform | this might take a few days | > | 03-18 Thu | earth | breath air | | > > If I wanted to add an extra day on mars I could just enter a new row, > recalculate the forumula, and the dates would be automagically updated. > It's not such a big deal in a small example like this but I'm planning out a > 3 week vacation with a fair number of destinations. I'd like the day of > week to display because some sites are closed on certain days. > > It goes without saying that I've spent more time trying to figure this out > than it would actually save so it's more about education at this point :) Well, you can use the full power of both Emacs Lisp and Emacs Calc in the org spreadsheet cells so the following works (although maybe it's not quite as pretty as you would like...): --8<---------------cut here---------------start------------->8--- | date number | date | activity | |-------------+--------------------+----------| | 733850 | | swim | | 733851 | | run | | 733852 | | eat | #+TBLFM: $1=1+@-1::$2='(calc-eval (concat "date(" $1 ")"))::@2$1='(calc-eval "date(now())");%d --8<---------------cut here---------------end--------------->8--- The first column are date numbers which are then shown in text in the second column. the first date is currently set to "today" but this could be any specific date by simply replacing "now()" by say "date(3,18)" for 18 March. I'm sure it can be done more expertly by others, of course, as I am definitely not up to speed with calc. Hope this helps.