MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Positions of earliest dates for each month in a list of dates

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106404] Positions of earliest dates for each month in a list of dates
  • From: Garapata <warsaw95826 at mypacks.net>
  • Date: Mon, 11 Jan 2010 18:52:55 -0500 (EST)

I have a list of 20+ years of dates (from earliest to latest) in
DateList format:

A subset of the list should suffice to illustrate:

myDates = {{1984,12,7,0,0,0}, {1985,1,3,0,0,0},{1985,1,4,0,0,0},
{1985,1,7,0,0,0}
,{1985,2,1,0,0,0},{1985,2,4,0,0,0},{1985,2,5,0,0,0},{1985,3,4,0,0,0},
{1985,3,5,0,0,0},
{1985,3,6,0,0,0},...};

The list does not include all dates, weekends and it may not include
some holidays or other seemingly arbitrary days.

I need to find out the positions of the the first date appearing in
each month.

So, from the sample of myDates above I need to get:

{1, 2, 5, 8}

Corresponding to the positions for the dates:

{{1984,12,7,0,0,0},
{1985,1,3,0,0,0},
{1985,2,1,0,0,0},
{1985,3,4,0,0,0}}

I've tried working with Position, Split, SplitBy, Ordering, Sort, and
Sortby, but haven't made much progress.

I've also tried creating an index for the dates like this:

SplitBy[Transpose[Join[{myDates}, {Range[1, Length[myDates]]}]]];

and hoped to use its output to sort or split the list into sublists of
each month then just use Part to take the first date in each month
with its paired index, but I still can't figure out how to do it.

I've got the feeling I've missed a simple solution to this, any help
much appreciated.


  • Prev by Date: Re: How to call an external program from Mathematica?
  • Next by Date: Re: How to call an external program from Mathematica?
  • Previous by thread: Problem: InverseLaplaceTransform with unexpected result
  • Next by thread: Re: Positions of earliest dates for each month in a list