Re: subtracting one date from another

[email protected] (Zefram)
Newsgroups perl.datetime
Message-ID <[email protected]>
jagdish eashwar wrote:
>$dur = $date1->delta_days($date2);

This is correct as far as it goes.

>print $dur->days,"\n";
># This gives me --------- "4"

Here the duration is being expressed in weeks plus days, and you're
only looking at the days portion.  $dur->weeks returns 4; the duration
is 4 weeks plus 4 days.  To get the duration expressed purely in days,
do $dur->in_units("days").

-zefram
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.