emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <ucecesf@ucl.ac.uk>
To: Josh Mattoon <joshmattoon@gmail.com>
Cc: Dan Davison <davison@stats.ox.ac.uk>, emacs-orgmode@gnu.org
Subject: Re: dates in a spreadsheet
Date: Thu, 18 Mar 2010 20:31:19 +0000	[thread overview]
Message-ID: <87aau5tlrc.wl%ucecesf@ucl.ac.uk> (raw)
In-Reply-To: <3a257d511003170951q342b2165vdcc51391c4277911@mail.gmail.com>

On Wed, 17 Mar 2010 09:51:04 -0700, Josh Mattoon <joshmattoon@gmail.com> wrote:
> 
> [1  <multipart/alternative (7bit)>]
> [1.1  <text/plain; ISO-8859-1 (7bit)>]
> 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 | <Thu Mar 18, 2010> | swim     |
|      733851 | <Fri Mar 19, 2010> | run      |
|      733852 | <Sat Mar 20, 2010> | 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.

      parent reply	other threads:[~2010-03-18 20:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17  6:04 dates in a spreadsheet Josh Mattoon
2010-03-17 15:18 ` Mikael Fornius
2010-03-17 15:26 ` Dan Davison
2010-03-17 16:51   ` Josh Mattoon
     [not found]     ` <11255.1268855898@alphaville.usa.hp.com>
2010-03-17 20:45       ` Josh Mattoon
2010-03-17 22:39         ` Bernt Hansen
2010-03-18  5:38           ` Carsten Dominik
2010-03-18 20:31     ` Eric S Fraga [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aau5tlrc.wl%ucecesf@ucl.ac.uk \
    --to=ucecesf@ucl.ac.uk \
    --cc=davison@stats.ox.ac.uk \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=joshmattoon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).