Loading ...
Sorry, an error occurred while loading the content.

DATE::MANIP number of days between two dates

Expand Messages
  • dachner2002
    How do I get the number of days between two dates using DATE::MANIP? This is all I can come up with but it gives me Weeks and Days, not just days.
    Message 1 of 4 , Apr 13, 2009
    • 0 Attachment
      How do I get the number of days between two dates using DATE::MANIP?

      This is all I can come up with but it gives me Weeks and Days, not just days.

      +0:0:4:5:0:0:0


      $date1 = ParseDate("05/10/1999");
      $date2 = ParseDate("06/12/1999");

      delta = DateCalc($date1,$date2,\$err,0);

      Thx,
      Don
    • Kalyan Raj
      Hello, I think Date::Time will give you best results use DateTime; use DateTime::Duration; use Date::Manip; my $dt = DateTime- now;         # same as (
      Message 2 of 4 , Apr 13, 2009
      • 0 Attachment
        Hello,

        I think Date::Time will give you best results

        use DateTime;
        use DateTime::Duration;
        use Date::Manip;

        my $dt = DateTime->now;         # same as ( epoch => time() )

        # Get today's date
        my ($day, $month, $year, $month_abbr);

        $year   = $dt->year;
        $month  = $dt->month;           # 1-12 - also mon
        $day    = $dt->day;             # 1-31 - also day_of_month, mday
        $month_abbr  = $dt->month_abbr;

        my $current = DateTime->new( year => $year, month =>$month, day => $day );

        # Get any old date to compare with...
        $date2= UnixDate($date2, "%d/%m/%Y");

        my ($day, $month, $year) = split(/\//, $date2);
        $date2= DateTime->new( year => $year, month =>$month, day => $day );

        my $duration = $current->subtract_datetime_absolute($date2);
        my $days = $duration->seconds / (60 * 60 * 24);


        --- On Tue, 4/14/09, dachner2002 <dachner@...> wrote:

        From: dachner2002 <dachner@...>
        Subject: [PBML] DATE::MANIP number of days between two dates
        To: perl-beginner@yahoogroups.com
        Date: Tuesday, April 14, 2009, 1:52 AM

















        How do I get the number of days between two dates using DATE::MANIP?



        This is all I can come up with but it gives me Weeks and Days, not just days.



        +0:0:4:5:0:0: 0



        $date1 = ParseDate("05/ 10/1999") ;

        $date2 = ParseDate("06/ 12/1999") ;



        delta = DateCalc($date1, $date2,\$ err,0);



        Thx,

        Don































        [Non-text portions of this message have been removed]
      • buxh42a
        http://faq.perl.org/perlfaq4.html#How_can_I_compare_tw Another way: use Date::Calc qw(Delta_Days); $days = Delta_Days( $year1, $month1, $day1, $year2, $month2,
        Message 3 of 4 , Apr 15, 2009
        • 0 Attachment
          http://faq.perl.org/perlfaq4.html#How_can_I_compare_tw

          Another way:

          use Date::Calc qw(Delta_Days);
          $days = Delta_Days( $year1, $month1, $day1, $year2, $month2, $day2);



          --- In perl-beginner@yahoogroups.com, "dachner2002" <dachner@...> wrote:
          >
          > How do I get the number of days between two dates using DATE::MANIP?
          >
          > This is all I can come up with but it gives me Weeks and Days, not just days.
          >
          > +0:0:4:5:0:0:0
          >
          >
          > $date1 = ParseDate("05/10/1999");
          > $date2 = ParseDate("06/12/1999");
          >
          > delta = DateCalc($date1,$date2,\$err,0);
          >
          > Thx,
          > Don
          >
        • dachner2002
          Date::Calc requires a C compiler to install so I ve stayed away from it. Don
          Message 4 of 4 , Apr 15, 2009
          • 0 Attachment
            Date::Calc requires a C compiler to install so I've stayed away from it.
            Don


            --- In perl-beginner@yahoogroups.com, "buxh42a" <buxh42a@...> wrote:
            >
            > http://faq.perl.org/perlfaq4.html#How_can_I_compare_tw
            >
            > Another way:
            >
            > use Date::Calc qw(Delta_Days);
            > $days = Delta_Days( $year1, $month1, $day1, $year2, $month2, $day2);
            >
            >
            >
            > --- In perl-beginner@yahoogroups.com, "dachner2002" <dachner@> wrote:
            > >
            > > How do I get the number of days between two dates using DATE::MANIP?
            > >
            > > This is all I can come up with but it gives me Weeks and Days, not just days.
            > >
            > > +0:0:4:5:0:0:0
            > >
            > >
            > > $date1 = ParseDate("05/10/1999");
            > > $date2 = ParseDate("06/12/1999");
            > >
            > > delta = DateCalc($date1,$date2,\$err,0);
            > >
            > > Thx,
            > > Don
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.