all groups > sql server connect > march 2006 >
You're in the

sql server connect

group:

Retrieve week # of the year



Re: Retrieve week # of the year SQL
3/1/2006 9:34:14 AM
sql server connect: use datepart

select datepart(wk,('01/08/06')),datepart(wk,getdate())


http://sqlservercode.blogspot.com/
Re: Retrieve week # of the year SQL
3/1/2006 9:57:33 AM
you don't need to, that was just to show you 2 values
The ISOWeek ifunction can be found here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create_7r1l.asp



http://sqlservercode.blogspot.com/
Retrieve week # of the year Preacher Man
3/1/2006 11:22:04 AM
Is there a SQL command I can use in a select statement to retrieve the week
of the year. For example a command of Year('01/08/06') would return 2006.
I am looking for a command like Week('01/08/06') to return 2. I cannot find
such a thing.

Thanks.

Re: Retrieve week # of the year Preacher Man
3/1/2006 11:48:34 AM
Excuse my ingorance, but how do you install the ISOWEEK function? I can't
find much info on it.

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:%237S53eVPGHA.2924@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

Re: Retrieve week # of the year Preacher Man
3/1/2006 11:52:56 AM
Why do I have to use the datepart(wk,getdate()) as part of the syntax?

[quoted text, click to view]

Re: Retrieve week # of the year Aaron Bertrand [SQL Server MVP]
3/1/2006 4:27:10 PM
Do you have Books Online? It's in there, I believe it's one of the CREATE
FUNCTION examples.

Also see http://www.aspfaq.com/2519 for a different approach, e.g. if you
have a different week numbering system than ISO or SQL Server's default
behavior...



[quoted text, click to view]

Re: Retrieve week # of the year Tibor Karaszi
3/1/2006 6:43:59 PM
No, don't use DATEPART for weeknumbers. The function doesn't calculate week numbers correctly.
Install the ISOWEEK function found in Books Online instead.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/


[quoted text, click to view]
AddThis Social Bookmark Button