I could never keep straight the various formats and datatypes the 
getdate, todate, and todayno routines use, and so nine months ago I 
wrote myself the following little utility for converting dates in any 
of the various formats I use to the equivalent day number.  It seems to 
work fine for single dates.  More recently I've had the need to feed it 
a list of dates (one of the columns of an array).  However, after 
spending all afternoon and evening at it, I just cannot seem to figure 
out how to handle the simultaneous calculation for all elements of the 
array list or column (implicit loop).  Rather than picking characters 
out of the date string for each date, it picks rows once instead.  I 
tried all sorts of things, to no avail.

----------------------------------------------------------
load 'dates'

date2num=: 3 : 0
  if. 0=(+/ ' ,-/:' e. y) do.
    y2=. ((i.4) { y),' ',(4 5 { y),' ',(6 7 { y)
  else.
    y2=. y
  end.
  todayno getdate y2
:
  todayno (1 getdate y)
)

datenum '20080101'   <-- works

aa=. > 
'20080101';'20080102';'20080103';'20080104';'20080105';'20080106';'20080
107';'20080109';'20080110'

datenum aa   <-- does NOT work  (this is what I'd like to do)

----------------------------------------------------------

Can anyone help?  (Explicit only, no tacit, please.)  Thanks!

Harvey

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to