in reply to Days between 2 dates ?

I'm not sure if you want to simply know the number of days between two given dates, or all of the dates between the two given dates, but Date::Simple and Date::Range can do what you want. i.e
#!/usr/bin/perl -w use strict; use Date::Simple; use Date::Range; # Define our dates my $date1 = Date::Simple->new('2006-02-02'); my $date2 = Date::Simple->new('2007-02-02'); # Create our range my $range = Date::Range->new($date1, $date2); # Find the number of days between the specified dates my $number_of_days = $range->length; print "Number of days between dates: $number_of_days\n"; # Now print each of these dates foreach my $date ($range->dates) { print $date->as_str . "\n"; }

Replies are listed 'Best First'.
Re^2: Days between 2 dates ?
by jflevi (Beadle) on Feb 26, 2008 at 23:24 UTC
    Thanks a lot for pointing me to this module; it was a breeze to install, and with
    use Date::Simple ('date');
    I just needed:
    $diff = date($enddate) - date($startdate);
    I had my question solved, simple and easy.

    You Monks ROCK !!!

    Life is tough, it's tougher when you are dumb...

    jfl