Hi Daisuke, I tried using DateTime.pm, however, it was costing me about 11 seconds for every 5,000 rows so I ended up using Time::Local and the localtime that came with Perl. Here is my sample code:
my ($year, $month, $day) = split('-', $prev[7]); my $m = $month; $m =~ s/^0//g; $m -= 1; my $d = $day; $d =~ s/^0//g; my $prevSecs = timelocal(0,0,0,$d,$m,$year); my ($YEAR, $MONTH, $DAY) = split('-', $fill_dte); my $M = $MONTH; $M =~ s/^0//g; $M -= 1; my $D = $DAY; $D =~ s/^0//g; my $fillSecs = timelocal(0,0,0,$D,$M,$YEAR); $diffInDays = int(($fillSecs - $prevSecs) / 86400); #print "diffInDays is: $diffInDays\n" if $DEBUG; if ($diffInDays <= 0) { $days_sply_secs = $prevSecs + (86400 * $days_sply); my ($cyear, $cmonth, $cday) = (localtime($days_sply_secs))[5,4,3]; $cyear += 1900; $cmonth += 1; $cmonth =~ s/^/0/ if ($cmonth < 10); $cday =~ s/^/0/ if ($cday < 10); $cted = "$cyear-$cmonth-$cday"; $class = "C"; } else { if ($diffInDays - $days_sply) <= $grace) { $class = "C"; } else { $class = "R"; } } Peter -----Original Message----- From: Daisuke Maki [mailto:[EMAIL PROTECTED] Sent: Thursday, September 07, 2006 6:44 PM To: Loo, Peter # PHX Cc: datetime@perl.org Subject: Re: Getting number of days between two dates using DateTime.pm Try using DateTime::Format::Duration with the %j pattern --d Loo, Peter # PHX wrote: > Hi, > > I am trying to obtain number of days difference between two dates. Is > it possible to do this using DateTime.pm? For example: > > 2006-09-06 - 2006-08-12 = 25 days > > The result that I want is 25 days. I tried using the > > $diff = $dur->in_units( 'days' ); > > but I am only getting the difference between 12 and 6. The difference > between the months is left out. > > Thanks. > > Peter > This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message.