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.
Author |
Topic |
ESSetif
Starting Member
2 Posts |
Posted - 2013-03-14 : 10:27:58
|
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-0000So 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
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-03-14 : 10:41:00
|
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. |
|
|
ESSetif
Starting Member
2 Posts |
Posted - 2013-03-14 : 10:53:37
|
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.
|
|
|
|
|
|
|
|