SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 YYYYWWD to YYYYMMDD
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

KalleS
Starting Member

Sweden
1 Posts

Posted - 10/25/2013 :  08:46:54  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 10/25/2013 :  08:59:08  Show Profile  Reply with Quote
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

Edited by - visakh16 on 10/25/2013 09:32:32
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 10/25/2013 :  14:49:57  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000