Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 YYYYWWD to YYYYMMDD

Author  Topic 

KalleS
Starting Member

1 Post

Posted - 2013-10-25 : 08:46:54
Hi,

I would like to convert a strange date format (YYYYWWD) to YYYYMMDD, anyone know how to solve this?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-25 : 08:59:08
yep. see this example

DECLARE @Date int
SET @Date = 2013034 --(2013 3rd week 4th day)

SELECT DATEADD(dd,(@Date%10)-1,DATEADD(wk,DATEDIFF(wk,0,DATEADD(yy,(@Date/1000)-1900,0))+((@Date%1000)/10)-1,0))


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-10-25 : 14:49:57
What constitutes a week? Which weekday number correlated to which weekday?



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -