How to get week of the month

Hi,

I want to display week of a particular month like for 10th August 2011,
should get week of the month as 2.

Thanks in advance.
Sulabha

hi Sulabha -

it seems you really just need the integer that represents the day from
the date (the month and year are irrelevant in determining the week of
the month…)

strip the number of the day off the string which is the date, and
convert that to a float (with #to_f). then divide it by 7.0 and call
#ceil on the result (which will round it up,) and you should have what
you’re looking for.

  • j

On Wed, Aug 3, 2011 at 12:14 PM, sulabha w. [email protected] wrote:

I want to display week of a particular month like for 10th August 2011,
should get week of the month as 2.

How are you defining “week of the month”?

What week is e.g. 5th September 2011 ? Is that 1 or 2 ?