Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当您拥有月份编号时,获取月份名称的最佳方法是
选择 DateName( 月 , DateAdd( 月 , @MonthNumber , 0 ) - 1 )
内部查询
select DateAdd( month , 12 , 0 )-1
将输出为
1900-12-31 00:00:00.000
Sql server 认为开始日期为 1900-01-01 00:00:00.000,该日期加上 12 个月将得到 1901-01-01 00:00:00.000
当您减去一天并取月份名称时,从此值中得到 december,这是您想要的输出