in reply to Calculating Number Of Pay Periods

use strict; use warnings; use DateTime; my $now = DateTime->now(time_zone=>'local'); $now->truncate(to=>'day'); my $then = DateTime->new(time_zone=>'local', year=>2019, month=>11, day=>23 ); print $now->ymd," to ",$then->ymd,"\n"; my $diff = $now->delta_md($then); my ($months,$days) = $diff->in_units('months','days'); print "$months months and $days days\n"; my $weeks = $now->delta_days($then)->in_units('weeks'); print "$weeks weeks\n"; __END__ 2017-10-08 to 2019-11-23 25 months and 15 days 110 weeks

Replies are listed 'Best First'.
Re^2: Calculating Number Of Pay Periods
by Anonymous Monk on Oct 08, 2017 at 22:47 UTC
    Worked like a champ! Thank you.