in reply to Re: Re: Multiple date ranges
in thread Multiple date ranges

What format are the timestamps in?

Convert the timestamps to seconds (use any means neccessary).

Create a datastructure resembling

$foo{'bar'} = [ 1, # first joined 2, # left 3, # joined again 4, # left 5, # joined again ];
If a user has an odd number of timestamps, he's still a member.

It's fairly obviouls how to go about querying for other values.

If the code is clean, switching to DBI needn't take more than a few days (i got a feeling its not though *shudder*).

Replies are listed 'Best First'.
Re: Re: Re: Re: Multiple date ranges
by AndyH (Sexton) on Feb 03, 2003 at 13:28 UTC

    The timestamps were entered as free text in a web form. No checking of any kind - pick a format, any format. I have a roughly 200 line perl regexp script that has got (nearly)all of them into ISO format (YYYY-MM-DD).

    Spotting who is currently a member is easy (apart from anything else, that info exists in another database I didn't tell you about). What I was looking for was a more elegant way of handling the other queries, e.g. using Date::Range, than a brute force approach...

      The timestamps were entered as free text in a web form.No checking of any kind - pick a format, any format. I have a roughly 200 line perl regexp script that has got (nearly)all of them into ISO format (YYYY-MM-DD).
      Did you give Date::Manip a try?? It's a big and slow module but quite good at parsing dates in any format, take a look at the ParseDate function. This could save you from having to program monsters like 200 line regex scripts ...

      -- Hofmator

      You know what, use DBD-SQLite.

      Date::Range is not for you (unless you got tons of memory, and wanna have 4500 Date::Range objects --- stupid)

      Build a new database out of your flat file, and SQL to query it any which way you want.

      The timestamps were entered as free text in a web form.
      I hope that's the #1 thing on your to-do list (give the users a pulldown menu, or simply use localtime/gmtime)

      You wanna handle SQL-esque type queries in a non-SQL way, you're gonna have to bend over backwards to do it.

      You need to involve another database and create kinds of indexes.