Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Finding the week number of the month

Author  Topic 

naveentnk
Starting Member

15 Posts

Posted - 2009-03-20 : 02:59:15
Hi Everybody,

Can anyone help me out to find the week of the month. It query or function should return number of the the week. If the first day of the month is starting on saturday(1st). The the nextday that is 2nd(sunday) should be treated as next week that is week 2.

Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.

naveentnk
Starting Member

15 Posts

Posted - 2009-03-20 : 04:45:53
can any one help me out

Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-20 : 05:10:05
Try this once,

declare @startmonth datetime,@endmonth datetime
select @startmonth = '1/1/2009' ,@endMonth = '12/31/2009'

SELECT number + 1 AS 'Day' ,DATEADD(DAY, number, @startmonth) AS 'Date',
datepart(ww,DATEADD(DAY, number, @startmonth)) AS 'Week',
DATENAME(dw,DATEADD(DAY, number, @startmonth)) AS 'WeekDay'
FROM Master..spt_values
WHERE type = 'P'
AND DATEADD(DAY, number, @startmonth) <= @endMonth
Go to Top of Page

naveentnk
Starting Member

15 Posts

Posted - 2009-03-20 : 07:20:00
hi Nageswarao,

Thank you



Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-20 : 07:58:10
quote:
Originally posted by naveentnk

hi Nageswarao,

Thank you



Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.



Welcome
Go to Top of Page
   

- Advertisement -