I only tested it real quick, but it seems ok. I would test it a little more
though, and maybe add some error checking.
use Time::Local;
$var1 = '2002-02-01';
$var2 = '2002-02-28';
print daysDiff($var1, $var2);
sub daysDiff {
$d1 = dateToTime($_[0]);
$d2 = dateToTime($_[1]);
return abs($d2 - $d1) / 86400;
}
sub dateToTime {
my $d = shift;
my @d = split(/-/, $d);
return timelocal(0,0,0,$d[2],$d[1]-1,$d[0]-1900);
}
Rob
-----Original Message-----
From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:19 PM
To: '[EMAIL PROTECTED]'
Subject: days calculation
Hi-
Does anyone know how to calculate number of days if the dates are
'2002-02-01' '2002-02-28'?
In other words, if var1='2002-02-01' and var2='2002-02-28' then
how can we say days=var2-var1?
thanks.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]