SQL 格式('MMMM')在 SQL Server 2008 中不起作用

沃尔特斯

我有这个查询

select 
    format([time], 'MMMM') as 'Month', 
    count([time]) as 'Application Usage', 
    count([time]) as 'Application Usage' 
from 
    UserLogs UL 
where 
    [time] >= Dateadd(Month, Datediff(Month, 0, DATEADD(m, -6, current_timestamp)), 0) 
    and Ul.UserId = @user 
group by
    format([time],'MMMM')

但是,我使用 SQL Server 2008 迁移到服务器,但出现此错误:

“格式”不是可识别的内置函数名称

我可以用什么来替换这个格式函数?

未处理的异常肖恩

这是 SQL Server 2012 及更高版本的一项功能。尝试DATENAME(MONTH,[time]).

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章