Right now I do not have Date::Calc installed and I'm trying to figure out how I can get the value in days of two dates. Here is my code to give you an idea of what I'm trying to accomplish.

If I somehow can get date::calc installed could I just then do $diff_in_days = Delta_days($sysdate, $installed_date)? Also in the event I can't install date::Calc can you please give a suggestion of how else to accomplish this?

use POSIX qw(strftime); use Time::Local; #use Date::Calc qw(:all); #use time::Piece; #use Date::Calc qw(Delta_Days); sub give_warning { my($carrier) = @_; my($installed_date); my($max_days) = 15; $installed_date = get_value($carrier ."_DAYS", $trn_info, '') ; printf("Value of Carrier Days is $installed_date \n"); if ($installed_date ne "" ) { my $sysdate = decode_date ('SYSDATE','CCYYMMDD'); printf("Todays date is $sysdate \n"); my $diff_in_days = $sysdate - $installed_date ; print "Difference in days: $diff_in_days\n"; if $result > $max_days # give error and return { &print_error ("New Installation is required."); return 1; } elsif $result <= $max_days # give warning and return { &print_warning ("New Installation is required."); return 0; } } else { return 0; } }

In reply to Re^2: Subtracting and Comparing Two Dates by mindful07
in thread Subtracting and Comparing Two Dates by mindful07

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.