emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* dates in a spreadsheet
@ 2010-03-17  6:04 Josh Mattoon
  2010-03-17 15:18 ` Mikael Fornius
  2010-03-17 15:26 ` Dan Davison
  0 siblings, 2 replies; 8+ messages in thread
From: Josh Mattoon @ 2010-03-17  6:04 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 412 bytes --]

I'm using the spreadsheet capabilities of org for the first time (very
cool!) to plan an upcoming trip.  I'd like to create a column formula to
automatically calculate the dates/day of week but I'm a bit stumped.  I
don't see a way for the formula to know which row it is currently
processing.  I'm also coming up short trying to find any elisp to go from
day of year -> formatted date string.  Any suggestions?

[-- Attachment #1.2: Type: text/html, Size: 626 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Mikael Fornius @ 2010-03-17 15:18 UTC (permalink / raw)
  To: Josh Mattoon; +Cc: emacs-orgmode


Can you give an example table of what you want to do?

I do not understand fully. 

| A                | B   |
|------------------+-----|
| [2010-03-16 Tue] | Tue |
| [2010-03-17 Wed] | Tue |
|                  |     |

Do you want to automatically extract the weekday from an org-mode
time-stamp in another column?

-- 
Mikael Fornius

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Dan Davison @ 2010-03-17 15:26 UTC (permalink / raw)
  To: Josh Mattoon; +Cc: emacs-orgmode

Josh Mattoon <joshmattoon@gmail.com> writes:

> I'm using the spreadsheet capabilities of org for the first time (very cool!)
> to plan an upcoming trip.  I'd like to create a column formula to automatically
> calculate the dates/day of week but I'm a bit stumped.  I don't see a way for
> the formula to know which row it is currently processing.  I'm also coming up
> short trying to find any elisp to go from day of year -> formatted date string.
>  Any suggestions?

Hi Josh,

Could you provide a small example table that shows the challenge you are
describing?

Dan


> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
  2010-03-17 15:26 ` Dan Davison
@ 2010-03-17 16:51   ` Josh Mattoon
       [not found]     ` <11255.1268855898@alphaville.usa.hp.com>
  2010-03-18 20:31     ` Eric S Fraga
  0 siblings, 2 replies; 8+ messages in thread
From: Josh Mattoon @ 2010-03-17 16:51 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1959 bytes --]

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 :)


On Wed, Mar 17, 2010 at 8:26 AM, Dan Davison <davison@stats.ox.ac.uk> wrote:

> Josh Mattoon <joshmattoon@gmail.com> writes:
>
> > I'm using the spreadsheet capabilities of org for the first time (very
> cool!)
> > to plan an upcoming trip.  I'd like to create a column formula to
> automatically
> > calculate the dates/day of week but I'm a bit stumped.  I don't see a way
> for
> > the formula to know which row it is currently processing.  I'm also
> coming up
> > short trying to find any elisp to go from day of year -> formatted date
> string.
> >  Any suggestions?
>
> Hi Josh,
>
> Could you provide a small example table that shows the challenge you are
> describing?
>
> Dan
>
>
> > _______________________________________________
> > Emacs-orgmode mailing list
> > Please use `Reply All' to send replies to the list.
> > Emacs-orgmode@gnu.org
> > http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

[-- Attachment #1.2: Type: text/html, Size: 2635 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
       [not found]     ` <11255.1268855898@alphaville.usa.hp.com>
@ 2010-03-17 20:45       ` Josh Mattoon
  2010-03-17 22:39         ` Bernt Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Mattoon @ 2010-03-17 20:45 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Dan Davison, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2479 bytes --]

Hey Nick, the first one came through just fine. This is pretty cool but
still not quite what I'm looking for.  It totally helped me get what I
wanted though!  I wanted to have a separate row for each day so I could fill
in activities.  Modifying your example I get:

| date             | place   | activity                  | notes
 |
|------------------+---------+---------------------------+------------------|
| <2010-03-19 Fri> |         |                           | dummy
 |
| <2010-03-20 Sat> |         |                           |
 |
| <2010-03-21 Sun> | moon    | collect rocks             |
 |
| <2010-03-22 Mon> | jupiter | thrash around the red dot |
 |
| <2010-03-23 Tue> | mars    | see the little green men  |
 |
| <2010-03-24 Wed> | earth   |                           | home, sweet home
|
#+TBLFM: @2$1 = <03-19-2010>::$1 = @-1$1 + 1

Exactly what I wanted!  I can insert days, move them around, and just hit
C-u C-c C-c to have it update.  I'd like to understand how it works though,
if you don't mind.  What does the ::$1 synax mean?  And how did it know that
we were dealing with a date?

On Wed, Mar 17, 2010 at 12:58 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:

> Josh Mattoon <joshmattoon@gmail.com> wrote:
>
> > 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.
>
> [Not sure what mailer mangled my previous reply to the point of
> unrecognizability, but here is another attempt - I hope it's
> cleaner. Let me know if there is a problem.]
>
>
> | date             | duration | place   | activity                  | notes
>            |
>
> |------------------+----------+---------+---------------------------+------------------|
> | <2010-03-17 Wed> |        0 |         |                           | dummy
>            |
> | <2010-03-17 Wed> |        3 | moon    | collect rocks             |
>            |
> | <2010-03-20 Sat> |        5 | mars    | see the little green men  |
>            |
> | <2010-03-25 Thu> |        5 | jupiter | thrash around the red dot |
>            |
> | <2010-03-30 Tue> |          | earth   |                           | home,
> sweet home |
> #+TBLFM: @2$1 = <03-17-2010>::$1 = @-1$1 + @-1$2
>

[-- Attachment #1.2: Type: text/html, Size: 3259 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
  2010-03-17 20:45       ` Josh Mattoon
@ 2010-03-17 22:39         ` Bernt Hansen
  2010-03-18  5:38           ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2010-03-17 22:39 UTC (permalink / raw)
  To: Josh Mattoon; +Cc: Dan Davison, emacs-orgmode

Josh Mattoon <joshmattoon@gmail.com> writes:

> Hey Nick, the first one came through just fine. This is pretty cool but still not quite what I'm looking for.  It totally helped me get what I wanted though!  I wanted to have a separate row for each day
> so I could fill in activities.  Modifying your example I get: 
>
> | date             | place   | activity                  | notes            |
> |------------------+---------+---------------------------+------------------|
> | <2010-03-19 Fri> |         |                           | dummy            |
> | <2010-03-20 Sat> |         |                           |                  |
> | <2010-03-21 Sun> | moon    | collect rocks             |                  |
> | <2010-03-22 Mon> | jupiter | thrash around the red dot |                  |
> | <2010-03-23 Tue> | mars    | see the little green men  |                  |
> | <2010-03-24 Wed> | earth   |                           | home, sweet home |
> #+TBLFM: @2$1 = <03-19-2010>::$1 = @-1$1 + 1
>
> Exactly what I wanted!  I can insert days, move them around, and just hit C-u C-c C-c to have it update.  I'd like to understand how it works though, if you don't mind.  What does the ::$1 synax mean?  And
> how did it know that we were dealing with a date?

As I understand it

This is a formula line with 2 formulas in it.  The formulas are
separated by the ::

@2$1 = <03-19-2010> sets the cell at row 2, column 1 to Mar 19, 2010

Then the next formula just calculates all of the values for column 1
leaving the static entry previously defined alone.

$1 = @-1$1 + 1   column 1 entries are the previous row for column 1 plus 1

so it just adds 1 to the initial value of the date for each following
row in your table.

HTH,
Bernt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: dates in a spreadsheet
  2010-03-17 22:39         ` Bernt Hansen
@ 2010-03-18  5:38           ` Carsten Dominik
  0 siblings, 0 replies; 8+ messages in thread
From: Carsten Dominik @ 2010-03-18  5:38 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: Dan Davison, emacs-orgmode


On Mar 17, 2010, at 11:39 PM, Bernt Hansen wrote:

> Josh Mattoon <joshmattoon@gmail.com> writes:
>
>> Hey Nick, the first one came through just fine. This is pretty cool  
>> but still not quite what I'm looking for.  It totally helped me get  
>> what I wanted though!  I wanted to have a separate row for each day
>> so I could fill in activities.  Modifying your example I get:
>>
>> | date             | place   | activity                  |  
>> notes            |
>> |------------------+---------+--------------------------- 
>> +------------------|
>> | <2010-03-19 Fri> |         |                           |  
>> dummy            |
>> | <2010-03-20 Sat> |         |                            
>> |                  |
>> | <2010-03-21 Sun> | moon    | collect rocks              
>> |                  |
>> | <2010-03-22 Mon> | jupiter | thrash around the red dot  
>> |                  |
>> | <2010-03-23 Tue> | mars    | see the little green men   
>> |                  |
>> | <2010-03-24 Wed> | earth   |                           | home,  
>> sweet home |
>> #+TBLFM: @2$1 = <03-19-2010>::$1 = @-1$1 + 1
>>
>> Exactly what I wanted!  I can insert days, move them around, and  
>> just hit C-u C-c C-c to have it update.  I'd like to understand how  
>> it works though, if you don't mind.  What does the ::$1 synax  
>> mean?  And
>> how did it know that we were dealing with a date?
>
> As I understand it
>
> This is a formula line with 2 formulas in it.  The formulas are
> separated by the ::
>
> @2$1 = <03-19-2010> sets the cell at row 2, column 1 to Mar 19, 2010
>
> Then the next formula just calculates all of the values for column 1
> leaving the static entry previously defined alone.
>
> $1 = @-1$1 + 1   column 1 entries are the previous row for column 1  
> plus 1
>
> so it just adds 1 to the initial value of the date for each following
> row in your table.

And the magic is that calc understands date and knows how to do
arithmetic with them.

- Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: dates in a spreadsheet
  2010-03-17 16:51   ` Josh Mattoon
       [not found]     ` <11255.1268855898@alphaville.usa.hp.com>
@ 2010-03-18 20:31     ` Eric S Fraga
  1 sibling, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2010-03-18 20:31 UTC (permalink / raw)
  To: Josh Mattoon; +Cc: Dan Davison, emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-18 20:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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).