Perl Monk, Perl Meditation | |
PerlMonks |
Re: Comparing Dates With a Twistby growlf (Pilgrim) |
on Nov 01, 2001 at 07:05 UTC ( [id://122488]=note: print w/replies, xml ) | Need Help?? |
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: 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.
In Section
Seekers of Perl Wisdom
|
|