while(my $row = $sth->fetchrow_hashref()) {
($cntct_date) = $row->{"CONTACT_DATE"};
####
$earliest_date = "30000101";
####
$date1 = ParseDate($earliest_date);
$date2 = ParseDate($cntct_date);
$flag = Date_Cmp($date1,$date2);
if ($flag<0) {
# date1 is earlier
print "$earliest_date was before $cntct_date.\n";
} elsif ($flag==0) {
# the two dates are identical
print "$earliest_date was THE SAME AS ($cntct_date).\n";
} else {
# date2 is earlier, so capture it:
print "$cntct_date was earliest--save it.\n";
$earliest_date = $cntct_date;
};