in reply to Script to display dates between range

One way, using DateTime:

use strict; use warnings; use DateTime qw( ); my $sdt = DateTime->new( year => 2010, month => 3, day => 9, ); my $edt = DateTime->new( year => 2010, month => 3, day => 16, ); for (my $dt = $sdt->clone(); $dt<=$edt; $dt->add( days => 1 )) { print($dt->ymd(), "\n"); }
2010-03-09 2010-03-10 2010-03-11 2010-03-12 2010-03-13 2010-03-14 2010-03-15 2010-03-16

Replies are listed 'Best First'.
Re^2: Script to display dates between range
by Anonymous Monk on Mar 10, 2010 at 03:33 UTC
    Thanks a lot for replying.....if I am giving an input in terms of string dates in the form of yyyy-mm-dd then how to handle such a input in above code
      You could use a regex to parse. You could use one of the DateTime::Format modules.
      use strict; use warnings; use DateTime::Format::ISO8601 qw( ); my $sdt = DateTime::Format::ISO8601->parse_datetime('2010-03-09'); my $edt = DateTime::Format::ISO8601->parse_datetime('2010-03-16'); for (my $dt = $sdt->clone(); $dt<=$edt; $dt->add( days => 1 )) { print($dt->ymd(), "\n"); }

      Or ...

        Thanks a lot.....I hope the above code will work for me.... God bless you !!!!