Hi wallflower,
the simple way is to convert the dates into a string of the format 'YYYY-MM-DD' and use the alphabetical compare operators (gt= greater then; lt= less then; eq= equal etc.).
If you would also need to know the number of days between the two given dates you may wana use the below code, which inculdes functions to convert the date into a such called julian date format (represents the number of days since 1. Jan. 4712 B.C.). On the other hand it also includes functions to convert a julian date into a calendar date.
#! c:/indigoperl/bin/Perl
use strict;
use Time::localtime;
my $TodayCD; #Used to hold the current calendar date
my $TodayJD; #Used to hold the current julian date value
my $PastDateCD='1995-10-11';
my $PastDateJD=CD2JD($PastDateCD);
my $FutureDateCD='2100-10-11';
my $FutureDateJD=CD2JD($FutureDateCD);
$TodayCD=(localtime->year()+1900) . "-";
$TodayCD=$TodayCD . sprintf("%02d",(localtime->mon()+1)) . "-";
$TodayCD=$TodayCD . sprintf("%02d",localtime->mday());
$TodayJD=CD2JD($TodayCD);
print "The PastDateCD is past since " . ($TodayJD-$PastDateJD) . " days\n";
print "The FutureDateCD is about to come in " . ($FutureDateJD-$TodayJD) . " days\n";
exit;
#===========================================================
# MonthFromJD(JulianDay); -> Calculates the Month of a
# Julian Date
#===========================================================
sub MonthFromJD
{
my $JD=$_[0];
my @Date;
my $Month;
my $CD;
$CD = JD2CD($JD);
@Date = split(/-/,$CD);
$Month = $Date[1];
return $Month;
}
#===========================================================
# DayFromJD(JulianDay); -> Calculates the Day of a Julian
# Date
#===========================================================
sub DayFromJD
{
my $JD=$_[0];
my @Date;
my $Day;
my $CD;
$CD = JD2CD($JD);
@Date = split(/-/,$CD);
$Day = $Date[2];
return $Day;
}
#===========================================================
# YearFromJD(JulianDay); -> Calculates the Year of a Julian
# Date
#===========================================================
sub YearFromJD
{
my $JD=$_[0]; #Assign input parameter to $JD
my @Date;
my $Year;
my $CD;
#Convert the Julian Day into a calendar date of the
#format 'YYYY-MM-DD'
$CD = JD2CD($JD);
#Use '-' as delimiter to split the date into its 3 parts.
@Date = split(/-/,$CD);
#Use the first part as return value
$Year = $Date[0];
return $Year;
}
#===========================================================
# JD2CD(JulianDay); -> Converts a Julian Date into a
# Calendar Date (e.g. "2002-10-15"

#===========================================================
sub JD2CD
{
my $JD=$_[0]; #Assign input parameter to $JD
#Some temporary variables
my $Z;
my $A;
my $Alpha;
my $B;
my $C;
my $D;
my $E;
#Variables for the resulting date
my $Day;
my $Month;
my $Year;
my $RetVal;
$Z = int($JD + 0.5);
#Base calculation of A
if ($Z < 2299161)
{
$A = $Z;
}
else
{
$Alpha = int(($Z - 1867216.25) / 36524.25);
$A = $Z + 1 + $Alpha - int($Alpha / 4);
}
#Calculate temporary values
$B = $A + 1524;
$C = int(($B - 122.1) / 365.25);
$D = int(365.25 * $C);
$E = int(($B - $D) / 30.6001);
#Calculate the day of month incl. the time fraction
$Day = $B - $D - int(30.6001 * $E);
#Calculate the month of the year
if ($E < 14)
{
$Month = $E - 1;
}
else
{
$Month = $E - 13;
}
#Calculate the year
if ($Month > 2)
{
$Year = $C - 4716;
}
else
{
$Year = $C - 4715;
}
#Calculate the calendar date
$RetVal = $Year . "-" . sprintf("%02d",$Month) . "-" . sprintf("%02d",$Day);
return $RetVal;
}
#===========================================================
# DayOfWeek(JulianDay); -> Day of the week (e.g. "Mo."

#===========================================================
sub DayOfWeek
{
my $RetVal=$_[0];
$RetVal +=1.5;
$RetVal %= 7; #Get the remainder of the modulu.
#Assign a weekday name (the example is in german language).
return ("So.","Mo.","Di.","Mi.","Do.","Fr.","Sa."

[$RetVal];
}
#===========================================================
# CD2JD(year, month, day); -> Converts a Calendar Date into
# a Julian Date
#
# The parameter for month and day are optional,
# if omitted, the function assumes the date to be
# stored in the year parameter, using the format
# 'YYYY-MM-DD'.
#===========================================================
sub CD2JD
{
my $Year=$_[0];
my $Month=$_[1]+0;
my $Day=$_[2]+0;
my @Date;
my $JD;
my $A;
my $B;
my $DateVal;
my $RetVal;
if (($Month == 0) && ($Day == 0))
{
@Date=split(/-/,$Year);
$Year=$Date[0];
$Month=$Date[1]+0;
$Day=$Date[2]+0;
}
$DateVal=$Year;
$DateVal.="-";
$DateVal.=sprintf("%02d",$Month);
$DateVal.="-";
$DateVal.=sprintf("%02d",$Day);
#moves the start of the year to the first of march
if ( $Month > 2)
{
$Year = $Year;
$Month = $Month;
}
else
{
$Year -= 1;
$Month += 12;
}
#Check if the date falls into the julian calendar (older
#calendar used until 04.10.1582) or into the gregorian
#calendar(newer calendar used since 15.10.1582)
if ($DateVal gt "1582-10-15"

{
$A = int($Year / 100);
$B = 2 - $A + int($A / 4);
}
else
{
$B = 0;
}
#Returns a double number with the days passed since -4712
#Jan. 0.0
$RetVal = int(365.25 * ($Year + 4716)) + int(30.6001 * ($Month + 1)) + $Day - 1524.5 + $B;
return $RetVal;
}