View Thread
 Print Thread
Function to convert weeknumber to date
admin
Function to convert weeknumber to date


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[udf_DateFromWeekNo] ( @wk INT, @yr INT )
RETURNS DATETIME
AS
    BEGIN

        DECLARE @newDate DATETIME
        SELECT  @newDate = DATEADD(week, @wk, DATEADD(year, @yr - 1900, 0)) - 4 - DATEPART(dw, DATEADD(week, @wk, DATEADD(year, @yr - 1900, 0)) - 4) + 1
        RETURN(@newDate)
    END
GO

Jordon Pilling | Heavencore Administrator
 
Jump to Forum