MathGroup Archive 2010

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

Search the Archive

Re: Re: Follow up to mg106646 - Selecting a range of

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107260] Re: [mg107227] Re: Follow up to mg106646 - Selecting a range of
  • From: Jason Ledbetter <jasonbrent at gmail.com>
  • Date: Sun, 7 Feb 2010 06:12:22 -0500 (EST)
  • References: <hkgl2o$6sq$1@smc.vnet.net> <201002060823.DAA14140@smc.vnet.net>

Albert,

Ah, thanks for pointing out my logic error.

I'd avoided using Select because it seemed to run MUCH longer than Cases.
However, it looks like all of my data isn't quite in the format I expected.

Thank you again....

-jbl

On Sat, Feb 6, 2010 at 3:23 AM, Albert Retey <awnl at gmx-topmail.de> wrote:

> Hi,
>
> > Given a list of date strings with each member in the list being in the
> > format of "Thu Nov 19 12:09:23 GMT 2009", what is the best method of
> > selecting matches between a date range?
> >
> > e.g., all data between November 1 2009 to November 8th 2009...
> >
> > I need to make sure this crosses year boundaries and such.
> >
> > My initial though is to convert the datestring into seconds since epoch
> and
> > do a basic numerical comparison between two ranges.
>
> basically I think that sounds like a very reasonable plan...
>
> > I've tried:
> >
> > Cases[zz, _?(AbsoluteTime[{"12/01/2009", {"Month", "Day", "Year"}}] >=
> >      AbsoluteTime[#[[1]]] <=
> >      AbsoluteTime[{"12/02/2009", {"Month", "Day", "Year"}}]) &]
> >
> >
> > where 'zz' is:
> >
> >
> > {{"Tue Dec 01 00:03:57 GMT 2009", 7370}, {"Tue Dec 01 04:57:23 GMT 2009",
> >   16179}, {"Mon Dec 07 20:50:04 GMT 2009",
> >   8546}, {"Wed Dec 09 00:29:57 GMT 2009", 9017}}
>
> And what is your question? I guess you would like to understand why the
> code does not do what you want, but the reason is rather trivial: you
> need a <= after the first AbsoluteTime to create a nontrivial condition.
> Note that there is also Select, which fits your use case better than Cases:
>
> Select[zz, (AbsoluteTime[{"12/01/2009", {"Month", "Day", "Year"}}] <=
>     AbsoluteTime[#[[1]]] <=
>    AbsoluteTime[{"12/02/2009", {"Month", "Day", "Year"}}]) &]
>
> hth,
>
> albert
>
>
>



  • Prev by Date: Re: Re: What does & mean?
  • Next by Date: Re: Re: Re: DeleteDuplicates is too slow?
  • Previous by thread: Re: Follow up to mg106646 - Selecting a range of dates?
  • Next by thread: Sort of nested NIntegrate