in reply to compare dates

Do you want to compare your dates in Perl or in SQL? You've received some good answers for comparing your dates in Perl. If you have a need to compare them in SQL, you would use Informix's string-to-date conversion and then compare the dates with the basic comparison operators.

I don't have experience with Informix; here's how it would look with DBI and Oracle, using TO_DATE to convert the string. This example looks for rows with a date_new column before 26/11/1987.

my $sth = $dbh->prepare(<<EndOfSQL); SELECT id FROM mytable WHERE date_new < TO_DATE(?, 'DD/MM/YYYY') EndOfSQL $sth->execute('26/11/1987'); while (my @row = $sth->fetchrow_array()) { print "@row\n"; }
I hope this is helpful; I would expect an Informix solution to look remarkably similar.

Replies are listed 'Best First'.
Re: Re: compare dates
by extremely (Priest) on Jan 15, 2001 at 02:07 UTC
    I ++'ed this because he is absolutely right, about 90% of the time, you should be doing your date compares in SQL. Data in a DB should be tested in a DB whereever possible just to lower the amount of network traffic you impose on the system.

    --
    $you = new YOU;
    honk() if $you->love(perl)