Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: DateManip Delta_Format Usage

by SBECK (Hermit)
on Jan 13, 2014 at 18:05 UTC ( #1070443=note: print w/replies, xml ) Need Help??

in reply to Re: DateManip Delta_Format Usage
in thread DateManip Delta_Format Usage

Sorry for the tardy reply... I don't get on perl monks more often than every few days.

The original post doesn't include the version they are using which is unfortunate. I'm assuming that it's from the pre 6.00 era. The '%dyd' style formats are from the newer version of Date::Manip, so they won't work with a 5.xx era script.

Also, the original post said he expected (not sure if it was good or bad) around 60+ days for both types of delta, and that shouldn't be a desired result since a business delta by definition is excluding a bunch of days (weekends) so it should be smaller by a factor of approximately 5/7.

If I wanted to know how many days were in the deltas, I'd do the following:

#Standard Days
my $standard_delta = DateCalc($start,$end,0);
my $standard_days  = Delta_Format($standard_delta,2,'%dt');
print "$standard_delta :: $standard_days\n";

#Business Days
my $business_delta = DateCalc($start,$end,3);
my $business_days  = Delta_Format($business_delta,2,'%dt');
print "$business_delta :: $business_days\n";

and the results were:

+0:0:9:4:0:0:0 :: 67.00
+0:0:0:47:0:0:0 :: 47.00

Note that I changed the business day calc mode to 3 (which is an exact business delta). By treating both exactly, you get accurate numbers which you won't get with approximate deltas.

Replies are listed 'Best First'.
Re^3: DateManip Delta_Format Usage
by wjw (Priest) on Jan 13, 2014 at 20:15 UTC
    That is informative! Thanks!
    ...the majority is always wrong, and always the last to know about it...
    Insanity: Doing the same thing over and over again and expecting different results.
Re^3: DateManip Delta_Format Usage
by nabrown737 (Initiate) on Jan 13, 2014 at 22:47 UTC

    Your reply is greatly appreciated, tardy or not! I wish I knew the version I was using, however that information seems to have been lost. I wasn't event aware that there was a 3rd mode for exact business delta. That is exactly what I needed! Thanks, Nathan

      The version is available (in almost every single module you can get from CPAN) as $VERSION in the module's namespace. For example, the following will usually work:

      use Foo::Bar;
      print $Foo::Bar::VERSION;

      For Date::Manip, that will work, or there's an alternative:

      use Date::Manip;
      print DataManipVersion();

      which just prints out that value.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1070443]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2020-10-26 07:54 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (250 votes). Check out past polls.