我将月份存储在SQL Server中为1,2,3,4,…12。我想把它们显示为一月,二月等。在SQL Server中有一个函数像MonthName(1) = 1月?如果可能的话,我尽量避免使用CASE语句。


当前回答

以下是我的工作:

CAST(GETDATE() AS CHAR(3))

其他回答

用最好的方式

Select DateName( month , DateAdd( month , @MonthNumber , -1 ))
to_char(to_date(V_MONTH_NUM,'MM'),'MONTH')

其中V_MONTH_NUM是月份号

SELECT to_char(to_date(V_MONTH_NUM,'MM'),'MONTH')  from dual;
SUBSTRING('JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC ', (@intMonth * 4) - 3, 3)
SELECT DateName(M, DateAdd(M, @MONTHNUMBER, -1))

这很简单。

select DATENAME(month, getdate())

产出:1月