Use timelocal and generate the time and then do the
calculations for days.
Something like:
# format for timelocal is
# seconds, minutes, hour, day of mohth, month
minus 1 and year (best format number of years since 1900)
# Following is just what you would do and you would need varaibles
or array holding that info
#
my $MyFirstDate =
timelocal(0,0,8,day,month-1,year-1900);
my $MySecondDate =
timelocal(0,0,8,day,month-1,year-1900);
my $MyDiff = $MySecondDate - $MyFirsDate;
my $MyDays = int($MyDiff/86_400);
You may or may not have to subtract the 1900. I
believe that I have left it at 2005 and it will do the correction ( at my age
could be wrong). Others will possibly suggest other modules, but not much
overhead or work if what you have is all that you are doing.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of [EMAIL PROTECTED]
Sent: Monday, October 31, 2005 09:08
To: [email protected]
Subject: Comparing dates
Gurus,
A simple one: what's the best, quickest, way to get the difference between two dates. They're both in the same format: "YYYYMMDD". One of them gets ginned up into that format starting from a call to time (that is, $x = time; stuff happens to $x; $y ends up "20051031";), the other's read in as a string from a file.
Thanks,
Deane
*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
