Hey Monks
I have a table of dated transactions, and I'm needing to detect any transactions dated more than 2 months into the future.
The following proof-of-conecpt code snippet is my attempt to achieve this result.
The $date variable will be filled using "SELECT date FROM table ORDER BY date DESC LIMIT 1"
The PoC seems to work, BUT can any monks help me do this a-better-way ?
TIA's for any tips or clues.

#!/usr/bin/perl use strict; use warnings; use DateTime; my $date = DateTime->new( time_zone => "UTC", year => 2019, month => 8, day => 10, ); my $now = DateTime->now; my $delta = $now - $date; my $months = $delta->{'months'}; my $days = $delta->{'days'}; print "Delta = $months months, and $days days\n"; print "*** Alert ***\n" if ($months < -2); exit(); __END__

In reply to Months between dates ? by bgroper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.