分类: 数据库开发技术
2009-12-04 16:58:22
sel cast(Substr('2009-1-3',1,4) ||
case when char(substr('2009-1-3',Index('2009-1-3','-')+1,
Index(
Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')-(Index('2009-1-3','-')+1)))=1 then '0' || substr('2009-1-3',Index('2009-1-3','-')+1,
Index(
Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')-(Index('2009-1-3','-')+1))
else
substr('2009-1-3',Index('2009-1-3','-')+1,
Index(
Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')-(Index('2009-1-3','-')+1))
end ||
case when char(substr(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,Index(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')+1))=1 then '0' || substr(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,Index(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')+1)
else
substr(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,Index(Case
When Position('-' In '2009-1-3') > 0
Then Substr('2009-1-3',1,Position('-' In '2009-1-3') - 1) || '*' || Substr('2009-1-3',Position('-' In '2009-1-3') + character_length('-'))
Else '2009-1-3'
End,'-')+1)
end as date format 'yyyymmdd') char_to_date;