in reply to Getting the current week number

That's tricky because of the ambiguity of what is meant by the first week of the month. Do you want to count partial weeks too? For example, if the month starts on a Monday (instead of a Sunday), do you want to count that first Monday-Saturday to be the first week? And if you do, will you also count months that start on a Thursday as having their first week be Thursday-Saturday?.... ...and, if you do, what if the first day of the month is a Saturday? Does that mean that week one of the month consists of one day only?

Once you work out the details that define the problem, you'll be well on your way to working out the details of implementing the solution.

And you also have to consider whos calendar you're using. When I worked for one corporation, the "Fiscal" calendar was quite different from the traditional calendar. We were on what we called a "4-5-5-4" schedule, meaning the "Months" all had exactly 4 or 5 weeks in them; exactly. Fiscal months always started on Sunday, and always ended on Saturday, no matter what the traditional calendar said. And that meant that June, for this corporation, might not be over until some time in the first week of what the rest of the world called July.

I've looked at Date::Manip and see that, though it does provide a Week-of-the-year function, it doesn't offer week-of-the-month. However, once you define your problem more tightly, you might have success using the Date_WeekOfYear() function and counting back to the first of the current month.


Dave