in reply to Date comparison

Rather straightforward using DateTime. Note that "14 months" is a vague term, especially on days like February 29 or around midnight.

#!/usr/bin/env perl use warnings; use strict; use feature qw{ say }; use DateTime; my $now = 'DateTime'->now; for my $day (6, 7) { my $dt = 'DateTime'->new(year => 2017, month => 6, day => $day); my $diff = $now - $dt; my ($years, $months) = ($diff->years, $diff->months); say $years == 1 && $months == 2 ? 'Yes' : 'No'; }

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Date comparison
by BillKSmith (Monsignor) on Aug 06, 2018 at 22:47 UTC
    If you are willing to learn only one module for time related calculations, DateTime is your friend. It probably is always overkill, but I have never encountered the task it could not handle.

    UPDATE: Corrected module name.

    Bill