Hi, Thanks a lot for posting your code. I had similar problem in which I wanted the number of working days between two dates taking holidays also into account. I referred your code and modified it as per my script.Using Date::Calendar and reading data from custom file. My file is :

# cat /home/otrsvpn/holiday.txt day1,23.10. day2,22.10. Gandhi Jayanti,02.10. Valentine's Day,14.02.

And my code

#!/usr/bin/perl use Date::Calendar; my $Holiday_File = "/home/otrsvpn/holiday.txt"; open FILE, $Holiday_File or die $!; my %holiday; my $holiday_ref = \%holiday; while (<FILE>) { chomp; my ($key, $val) = split /,/; $holiday{$key} .= exists $holiday{$key} ? "$val" : $val; } $calendar = Date::Calendar->new( $holiday_ref ); $days = $calendar->delta_workdays (2015,10,01,2015,10,30,1,0); print " \n There are $days days between 01-10-2015 and 30-10-2015 \n";

This simply prints the number of working days(weekdays and holidays) between the mentioned two dates. Thanks Again

# perl holiday.pl There are 18 days between 01-10-2015 and 30-10-2015

In reply to Re^2: Calculating next business day (weekends/holidays taken into account) by Hemant1612
in thread Calculating next business day (weekends/holidays taken into account) by vxp

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.