Also today in the SQL group asked, it seems that the problem is very simple, but I do not know how to achieve the specific. Baidu has a, to find a master contribution to the answer, remember.
convert Chinese dates in reference link sql
------with related functions------Create functionConvertnumtochinese (@instr varchar(2))returns varchar(2) asbeginDeclare @temStr varchar(2)if @instr = '1' Set @temStr = 'a'if @instr ='2' Set @temStr = 'two'if @instr ='3' Set @temStr = 'three'if @instr ='4' Set @temStr = 'Four'if @instr ='5' Set @temStr = 'Five'if @instr ='6' Set @temStr = 'Six'if @instr ='7' Set @temStr = 'Seven'if @instr ='8' Set @temStr = 'Eight'if @instr ='9' Set @temStr = 'Nine'if @instr ='0' Set @temStr = '0'return @temstrEnd --------------Implementation Key-stored procedure--------------------Create procedureConvertdatetochinese@vdate datetime,@ChineseDateStr varchar( -) out asDeclare @vYear varchar( -)Declare @vMonth varchar( -)Declare @vDay varchar( -)Declare @temstr varchar( -) Set @temstr = "'Set @vYear = Datename(yyyy,@vdate)--Print @vyearSet @vMonth = Datename(MM,@vdate)--Print @vMonthSet @vDay = Datename(DD,@vdate)--print ' V ' [email protected]--Start calculation YearSet @temstr =Dbo.convertnumtochinese (substring(@vYear,1,1))Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vYear,2,1))Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vYear,3,1))Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vYear,4,1))Set @temstr = @temstr + 'years' --Start Calculation Monthif substring(@vMonth,1,1)= '0'Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vMonth,2,1))Elsebegin if substring(@vMonth,2,1)= '0' Set @temstr = @temstr + '10' Else Set @temstr = @temstr +'10'+Dbo.convertnumtochinese (substring(@vMonth,2,1))End Set @temstr = @temstr + 'Month' --Start Calculation Date if Convert(int,@vDay)< Ten Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vDay,1,1))Elsebegin if substring(@vDay,2,1)= '0' begin if substring(@vDay,1,1)<> '1' Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vDay,1,1))+ '10' Else Set @temstr = @temstr + '10' End Else begin if substring(@vDay,1,1)<> '1' Set @temstr = @temstr +Dbo.convertnumtochinese (substring(@vDay,1,1))+ '10' +Dbo.convertnumtochinese (substring(@vDay,2,1)) Else Set @temstr = @temstr + '10' +Dbo.convertnumtochinese (substring(@vDay,2,1)) EndEndSet @temstr = @temstr + 'Day' Print @temstrSet @ChineseDateStr = @temstr
View Code
Call Method:
Declare @str_format varchar (a); exec ' 2017-11-08 13:30 ',@str_format outputselect@str_format
Results:
SQL Server Month Day turn Chinese character capitalization