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
 General SQL Server Forums
 New to SQL Server Programming
 Processing a Date Value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ESSetif
Starting Member

USA
2 Posts

Posted - 03/14/2013 :  10:27:58  Show Profile  Reply with Quote
Hello Everyone,

So I have a column in my table which is date and its represented as four numbers.
example : 1109 stands for year 2011 and month 9 ( September )

So am trying to transfer the 1109 to this : 2011-09-01-0000
So basically for day its always going to be 01 and for time its going to be zeros 0000, and pad dashes between the values.

this is what I managed to get so far
============================================================
select

case when convert(int, left(edate, 2)) < 70 then '20' + left(edate,2) else '19' + left(edate,2)

end as 'DATE'
from Emp_Date wh

=============================================================

thanks in advance

webfred
Flowing Fount of Yak Knowledge

Germany
8683 Posts

Posted - 03/14/2013 :  10:41:00  Show Profile  Visit webfred's Homepage  Reply with Quote
select

case when convert(int, left(edate, 2)) < 70 then '20' + left(edate,2) else '19' + left(edate,2) end
+ '-'
+ right(edate,2)
+ '-'
+ '01'
+ '-'
+ '0000' as 'DATE'
from Emp_Date wh


Too old to Rock'n'Roll too young to die.
Go to Top of Page

ESSetif
Starting Member

USA
2 Posts

Posted - 03/14/2013 :  10:53:37  Show Profile  Reply with Quote
thanks :)
quote:
Originally posted by webfred

select

case when convert(int, left(edate, 2)) < 70 then '20' + left(edate,2) else '19' + left(edate,2) end
+ '-'
+ right(edate,2)
+ '-'
+ '01'
+ '-'
+ '0000' as 'DATE'
from Emp_Date wh


Too old to Rock'n'Roll too young to die.

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.08 seconds. Powered By: Snitz Forums 2000