require'dates'
todayno getdate'1989 feb 5 '
69066
todayno getdate'1989 sep 5 '
69278
69278 -69066
212
todayno getdate'1990 feb 5 '
69431
69431-69278
153
2007/4/8, Boyko Bantchev <[EMAIL PROTECTED]>:
On 4/8/07, Brian Schott <[EMAIL PROTECTED]> wrote:
> In casual conversation we talk about how far apart
> our birthdays are...
Perhaps this one is worth considering.
days=: 31 28 31 30 31 30 31 31 30 31 30 31
datediff=: 4 : 0
'm d'=. y-x
(12|m-d<0), d+(days{~12|2-~{.y)*d<0
)
Examples:
a=. 11 5 NB. Nov 5
b=. 1 19 NB. Jan 19
a datediff b
2 4 NB. 2 months 4 days from a to b
b datediff a
9 17 NB. 9 months 17 days from b to a
3 25 datediff 6 25
3 0 NB. 3 months from Mar 25 to the same date in June
Of course, there still remains the need to deal with leap
years properly, but I am too lazy to do that :)
Regards,
Boyko
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: [EMAIL PROTECTED]
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm