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

Re: Comparing two dates and finding out number of days

by erroneousBollock (Curate)
on Nov 15, 2007 at 15:29 UTC ( [id://650993]=note: print w/replies, xml ) Need Help??


in reply to Comparing two dates and finding out number of days

I am not allowed to use any new modules as this script has to be run on multiple computers.
That's just silly. If your admins don't allow new modules to be installed, use the Perl Archive Toolkit to bundle up requisite modules into archives to be distributed with your script.

Use Date::Calc like this:

use Date::Calc qw/Delta_Days/; use strict; my @date1 = (2007, 12, 24); # or split '-', '2006-12-24'; my @date2 = (2009, 4, 16); # or split '-', '2009-4-16'; my $days = Delta_Days(@date1, @date2); print "There are $days days between ". sprintf('%04d-%02d-%02d',@date1)." and ". sprintf('%04d-%02d-%02d',@date1).".\n";

-David

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found