我在 SQL Server 中存储的月份为 1,2,3,4,...12。我想将它们显示为一月、二月等。SQL Server 中是否有类似 MonthName(1) = January 的函数?如果可能的话,我试图避免使用 CASE 语句。
最佳答案
我认为当您有月份编号时,这是获取月份名称的最佳方式
Select DateName( month , DateAdd( month , @MonthNumber , 0 ) - 1 )
或者
Select DateName( month , DateAdd( month , @MonthNumber , -1 ) )
关于sql - SQL 中将月份编号转换为月份名称函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/185520/