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 |
|
Senthilkumar
Starting Member
2 Posts |
Posted - 2007-11-19 : 12:26:33
|
| Hi,Actually i tried to convert the datetime value in yyyymmdd format from the int data type field.But except the first record it is looking fine.i cann't understand why this is happening? can you help me to resolve this problem?Select ABECDT,case when ISDATE(cast(ABECDT as varchar))=1 then cast(ABECDT as varchar) when len(cast(ABECDT as varchar))=8 then right(cast(ABECDT as varchar),4)+''+left(cast(ABECDT as varchar),2)+''+substring(cast(ABRDAT as varchar),3,2)when len(cast(ABECDT as varchar))=7 then right(cast(ABECDT as varchar),4)+'0'+left(cast(ABECDT as varchar),1)+''+substring(cast(ABRDAT as varchar),2,2)when len(cast(ABECDT as varchar))=6 then case when right(cast(ABECDT as varchar),2)<50 then '20' else '19' end+right(cast(ABECDT as varchar),2)+''+substring(cast(ABECDT as varchar),3,2)+''+left(cast(ABECDT as varchar),2) else NULL end from parmResult i got it from the above queryActual Value Result from the query11012001 2001111110012002 2002100112011998 199812012011998 199802106012002 20020601Can anyone help me to resolve this?Thanks and RegardsSenthil |
|
|
anonymous1
Posting Yak Master
185 Posts |
Posted - 2007-11-19 : 14:23:54
|
| you are building the date from multiple fields...ABRDAT looks like a typo in two places. |
 |
|
|
Senthilkumar
Starting Member
2 Posts |
Posted - 2007-11-19 : 15:15:56
|
Yes,I got it thanks for your helpquote: Originally posted by anonymous1 you are building the date from multiple fields...ABRDAT looks like a typo in two places.
|
 |
|
|
|
|
|
|
|