http://www.perlmonks.org?node_id=993469


in reply to No: of weeks in a month

The question you ask is ambiguous:   September 2013 begins on a Saturday and ends the following Sunday ... how many weeks, to you, is that?   You might say six, or you might say four.   Date-calculation routines are available in abundance on CPAN, but first you must nail-down the exact meaning of the question for you.   See for example Date::Calc, Date::Manip for the math heavy-lifting.

Replies are listed 'Best First'.
Re^2: No: of weeks in a month
by DrHyde (Prior) on Sep 13, 2012 at 12:58 UTC

    Or you might say 30/7 == 4 and 2/7.

    You might even say 5, if your definition of a week being in a month is that it begins in that month - those being the weeks beginning on the 2nd, 9th, 16th, 23rd and 30th.

Re^2: No: of weeks in a month
by daxim (Curate) on Sep 13, 2012 at 13:32 UTC
    The question you ask is ambiguous
    No, it isn't. We have a standard that defines what a week is.

      But that ISO standard has no definition of what defines weeks per month.

      A week is clearly defined but not how it relates to the entity of the month. I think it's safe to assume that the OP meant it to be the number of weeks that either fall completely within the month and those that are transected by the beginning and end of the month.