Calculating The Weeks Of A Month With ColdFusion

Published: {ts '2012-08-14 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/calculating-the-weeks-of-a-month-with-coldfusion/

I'm taking a little break from blogging this week to try get on top of my work load. To fill the gap until then here are two little functions I wrote a while back for getting the weeks in a month.

These come in useful for projects where you have to interface with reporting systems with numbered weeks in a month. They are also useful for calendar apps.

Weeks In Month

This function calculates how many weeks are in a given month.

Get The Current Week Number In The Month

Get the week number in a month of a given date.

Testing

Heres a quick example for testing these functions.

weeks in month: #weeksInMonth(now())#
Current Week: #weekOfMonth(now())#

Hope these come in useful. I should be back blogging next week once my work load levels off a bit (fingers crossed) :-).