Thursday, February 22, 2007

Week of Month

I have been experiencing many time with such requests like 'Give me number of week fo given date' , do you?
Actually we use here a simple logic.
Week number for given date minus a formated given date to the first date of the month (20070201) plus 1

CREATE FUNCTION dbo.WeekOfMonth (@now_day DATETIME)
RETURN DATEPART(week, @now_day) - DATEPART(week, CONVERT(CHAR(6), @now_day, 112)+'01') + 1
SELECT dbo.WeekOfMonth('20070201') AS [1st]
SELECT dbo.WeekOfMonth('20070209') AS [2nd]


Rob said...

Perfect! I searched high and low for this...thanks for posting.

haiyan said...

Regardless of the debate, North American games now have the chance to play Ragnarok Online with all kinds of ro zeny. During the free open Beta test period that you do not cost any ragnarok zeny, over ten thousand people logged on the game daily. Soon after this latest period, on a week notice, players were informed that the game was going pay iro zeny to play again. Each type of weapon, daggers and two handed swords, bows and so on which can gain from cheap zeny, have a unique animation for every class and sex. All ragnarok online zeny has the end effect of making every series of dungeons or outdoor maps look exactly alike.

aiya said...
This comment has been removed by a blog administrator.