Hi Gus.
Maybe I am way out in left field here, but if you are talking database, and you are probably using DBI to access it.. (such as DBD::CSV
http://www.perldoc.com/perl5.6.1/lib/DBD/CSV.html) why not just use the SQL functions to query for exactly what you want? Perhaps even make the DB query a sub that takes a date-delta as an argument that it will embed in the prepared query.
An extremely quick (and overly simplistic) example SQL statement that might do the trick for you is:
select
mydatefield,
myvaluestuff
from
mytable
where
mydatefield between (CURRENT_DATE)-90 and CURRENT_DATE
But, please be aware that I did not protect the date type in that query. You will need to determine more what you want to do in your query, what DBD to use, and use the apropriate functions in SQL.
Optionaly, you could also use the other SQL functions to parse a partial date field if the data is not actually stored as a date in the file (i.e. your date is in it's own field) such as to_date and date_part.
You might also gain some additional advantages by using DBI if you are not already doing so on your flatfile db.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.