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.
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 outWho 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. |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-03-20 : 05:10:05
|
Try this once,declare @startmonth datetime,@endmonth datetimeselect @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_valuesWHERE type = 'P' AND DATEADD(DAY, number, @startmonth) <= @endMonth |
|
|
naveentnk
Starting Member
15 Posts |
Posted - 2009-03-20 : 07:20:00
|
hi Nageswarao,Thank youWho 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. |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-03-20 : 07:58:10
|
quote: Originally posted by naveentnk hi Nageswarao,Thank youWho 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 |
|
|
|
|
|
|
|