in reply to Re: Subtracting and Comparing Two Dates
in thread Subtracting and Comparing Two Dates

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; } }

Replies are listed 'Best First'.
Re^3: Subtracting and Comparing Two Dates
by ikegami (Patriarch) on Jan 11, 2007 at 22:45 UTC
    Why do you want me to look at this? The code in the post to which you replied does exactly what you want.
      I apologize. I've tried so many suggestions and I thought when I tried to use local:time(timegm) it had given me an error when i tried to include it. It works just fine. Thanks again for your help!