Originally posted by Pedalen
In my database I am storing a delivery week in format YYYYWW, ie '200245'. Now I want to display this as a date.
I want the first date for the week to display as DD MMM YYYY, ie '04 Nov 2002'.
Does anyone know any simple way to do this?
You can use a T-SQL statement such as:
DECLARE @WK_DTE CHAR(6),
SET @WK_DTE = '200245'
SET @YR = LEFT(@WK_DTE,4)
SET @WK = CAST(RIGHT(@WK_DTE,2) AS INT)
SELECT CONVERT(CHAR(11), DATEADD(WEEK,@WK,'01/01/' + @YR), 106)
you could put this into a function or a stored procedure