Skip to content
Advertisement

create fiscal week number

How can I put the below logic into a format SQL Server will use to create a fiscal week number ?

if (datepart(week,getdate())-4) <= 0  then (datepart(week,getdate())+49) else (datepart(week,getdate())-4)

Advertisement

Answer

The CASE Statement should work:

CASE 
    WHEN (datepart(week,getdate())-4) <= 0
        THEN datepart(week,getdate())+49
    ELSE
        datepart(week,getdate())-4
END
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement