Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Want to use Date module

by davorg (Chancellor)
on Jun 26, 2009 at 13:18 UTC ( [id://775051]=note: print w/replies, xml ) Need Help??


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.

--

See the Copyright notice on my home node.

Perl training courses

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://775051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found