in reply to Want to use Date module
Am I using Date::Calc properly?
You're not actually using Date::Calc at all. Well, I mean you're loading the module. But then you're completely ignoring it. You're just incrementing a string.
I recommend DateTime for all date and time processing tasks.
#!/usr/bin/perl use strict; use warnings; use DateTime; my $start = DateTime->new(year => 2009, month => 5, day => 16); my $end = DateTime->new(year => 2009, month => 6, day => 2); my $curr = $start; while ($curr <= $end) { print $curr->strftime('%Y%m%d'), "\n"; $curr->add(days => 1); }
Update: Corion's point about doing this in the database is an excellent one.
|
|---|