Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Is there any CPAN modules to check two dates only are match( if i pass time along with date. The time should be negleced).Even if the dates are in any format..

2006-03-21 Retitled by planetscape, as per Monastery guidelines
Original title: 'Date question'

Replies are listed 'Best First'.
Re: How to compare two dates (any format)?
by liverpole (Monsignor) on Mar 21, 2006 at 12:22 UTC
    Or, if you happen to have the dates already in timet format, you can just write the subroutine yourself; it's quite short.  It takes less time than downloading any modules, and you have the fun of doing it yourself, as well as learning how to do it.

    Here's a working example:

    # Inputs: $1 ... date 1, as a timet # $2 ... date 2, as a timet # # Outputs: $1 ... nonzero if the dates match, ignoring the actual tim +es # of day for each, zero if they are different. # sub same_date { my ($timestamp1, $timestamp2) = @_; my ($day1, $month1, $year1) = (localtime $timestamp1)[3,4,5]; my ($day2, $month2, $year2) = (localtime $timestamp2)[3,4,5]; return ($day1 == $day2 && $month1 == $month2 && $year1 == $year2); }

    @ARGV=split//,"/:L"; map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"
Re: How to compare two dates (any format)?
by Anonymous Monk on Mar 21, 2006 at 10:49 UTC
    Take a look at Date::Manip's ParseDate function to normalize the two dates, and then the module of your choice to compare them (or just compare them as numbers).
Re: How to compare two dates (any format)?
by bcornett (Sexton) on Mar 21, 2006 at 12:29 UTC
    The DateTime module surely has what you need.