DATENAME(MONTH,GETADATE()) is returning numeric value of the month as '09'

故事扮演 提交于 2020-01-10 04:28:18

问题


When I run the following query [SELECT DATENAME(MONTH,GETDATE())], ideally speaking it should return value as 'September' but its returning value as '09'. I am running this query on MS SQL Server 2005. Is there anything I need to configure with MS SQL Server 2005?

Please find the details of the SQL Server 2005

Component Name                                Version
--------------------------------------------------------------------
Microsoft SQL Server Management Studio        9.00.1399.00
Microsoft Analysis Services Client Tools      2005.090.1399.00
Microsoft Data Access Components (MDAC)       2000.086.3959.00 (srv03_sp2_rtm.070216-1710)
Microsoft MSXML                               2.6 3.0 4.0 5.0 6.0 
Microsoft Internet Explorer                   6.0.3790.3959
Microsoft .NET Framework                      2.0.50727.42
Operating System                              5.2.3790

回答1:


SELECT @@LANGUAGE -> gives an Asian one?

SET LANGUAGE Japanese
SELECT DATENAME (month, GETDATE())

SET LANGUAGE us_english
SELECT DATENAME (month, GETDATE())

DATENAME depends on language, so need to change server default or your login default language...

Thank you and sayonara...




回答2:


Hmmmm, I get "September", SqlServer 2005 9.00.3402.




回答3:


Nope, SELECT DATENAME(month, GETDATE()); returns September for me. I just tried it in SQL 2005 and 2008. Where are you executing this query? That may help as to why this is happening to you.




回答4:


The only thing I can think of would be collation causing that, but I can't find any specific examples of a collation that would do that. The other possibility could be the language which also sets date format. I'm a bit mystified, but these are places to start.




回答5:


Try running:

select name ,alias, dateformat from syslanguages where langid = (select value from master..sysconfigures where comment = 'default language')

To see what language the system thinks it's using. SqlServer changes its date format based on that.



来源:https://stackoverflow.com/questions/1497952/datenamemonth-getadate-is-returning-numeric-value-of-the-month-as-09

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!