•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,536 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 2442 | Replies: 1
![]() |
•
•
Join Date: Sep 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I need a view with weeknumbers according to ISO. This means 1-1-2006 is week 53.
Now I created a function:
[MS SQL] CREATE FUNCTION dbo.WOY
( @Date DATETIME )
RETURNS SMALLINT
AS
BEGIN
DECLARE @WEEK SMALLINT
IF DATEPART(dw, CAST('1-1-' + CAST(DATEPART(YYYY, @Date) AS VARCHAR) AS DATETIME)) > 4
IF DATEPART(ww, @Date) = 1
SET @WEEK = 53
ELSE SET @WEEK = DATEPART(ww, @Date) -1
ELSE SET @WEEK = DATEPART(ww, @Date)
RETURN ( @WEEK )
END[/MS SQL]
In a view I added a column WOY(Date)
Now I need somehow set the datefirst to 1 but how can I do that?
Anyone?
I need a view with weeknumbers according to ISO. This means 1-1-2006 is week 53.
Now I created a function:
[MS SQL] CREATE FUNCTION dbo.WOY
( @Date DATETIME )
RETURNS SMALLINT
AS
BEGIN
DECLARE @WEEK SMALLINT
IF DATEPART(dw, CAST('1-1-' + CAST(DATEPART(YYYY, @Date) AS VARCHAR) AS DATETIME)) > 4
IF DATEPART(ww, @Date) = 1
SET @WEEK = 53
ELSE SET @WEEK = DATEPART(ww, @Date) -1
ELSE SET @WEEK = DATEPART(ww, @Date)
RETURN ( @WEEK )
END[/MS SQL]
In a view I added a column WOY(Date)
Now I need somehow set the datefirst to 1 but how can I do that?
Anyone?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
- Function help/homework (C++)
- DST II Bug coming in one week (Windows NT / 2000 / XP / 2003)
- My own read function (C)
- Please help me (Java)
- please help (Computer Science and Software Design)
- Project Help: Growth of a Function (Java)
- Help with Class, stuck. (C++)
Other Threads in the MS SQL Forum
- Previous Thread: Insert Into Syntax Problem
- Next Thread: Trouble_MSSQL Reporting Services 2000


Linear Mode