As others have noted, there are several ways to do calculations (exact, approximate, semi-approximate). Unfortunately, Date::Manip::DM6 (which is basically just an interface that is backward compatible with the older versions of Date::Manip) didn't currently support all of them (since they didn't even exist in older versions of Date::Manip).

The was no reason NOT to support them... I just had never thought to add them (and nobody had requested that). So I just did, and in the next version of Date::Manip, you'll be able to do:

my $dtopt= DateCalc($dt1,$dt2,'semi');

and get what you want. However, that won't work in the current version.

Getting what you want with the current version of Date::Manip::DM6 is harder because in the older module, there were only exact and approximate, and in newer versions there are exact, semi-approximate, and approximate, and it's challenging to get what you want. Really, the best way would be to do that calculation using the OO interface:

use Date::Manip::Date; my $date1 = new Date::Manip::Date; my $date2 = $date1->new_date(); $date1->parse($dt1); $date2->parse($dt2); my $delt = $date1->calc($date2,'semi'); my $delv = $delt->value(); print "$delv\n";

In reply to Re: DateCalc using Date::Manip by SBECK
in thread DateCalc using Date::Manip by tsdesai

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.