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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert year-Week column to year-month-Day
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nerd12
Starting Member

3 Posts

Posted - 02/09/2013 :  11:43:13  Show Profile  Reply with Quote
Hi,

I have a column called "date_time" in SQL 2005. this column is of format yyyyww. where ww= number of week in a year. So the format looks like '201243' or 201213 etc

I want to convert this column to YYYYMMDD format. In other words, '20120122' ..'20130101' etc.

Can someone please help me understand how can this column date_time be converted from yyyyww to yyyymmdd

Thank you!!

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/09/2013 :  12:22:33  Show Profile  Reply with Quote

SELECT DATEADD(wk,(date_time%100)-1,DATEADD(yy,(date_time/100)-1900,0)) AS Date_YMD
FROM table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nerd12
Starting Member

3 Posts

Posted - 02/09/2013 :  14:12:55  Show Profile  Reply with Quote
THANK YOU Visakh!! That worked
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/11/2013 :  00:50:18  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next 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.03 seconds. Powered By: Snitz Forums 2000