具有区域性参数的SQL Server FORMAT不起作用

问题描述 投票:0回答:1

我正在使用SQL Server 2017,并尝试在Format函数中使用区域性。在服务器上运行此查询时,结果不正确:

SELECT @@VERSION --> Microsoft SQL Server 2017 (RTM-CU17) (KB4515579) - 14.0.3238.1 (X64)   Sep 13 2019 15:49:57   Copyright (C) 2017 Microsoft Corporation  Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64
SELECT FORMAT(SYSDATETIME(), N'Y', 'fa'); --> February 2020

但是在带有SQL Server 2017的另一台服务器中运行此脚本时,脚本运行良好:

SELECT @@VERSION --> Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64)   Dec 22 2017 16:13:22   Copyright (C) 2017 Microsoft Corporation  Enterprise Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 16299: ) 
SELECT FORMAT(SYSDATETIME(), N'Y', 'fa'); --> بهمن, 1398

必须检查哪些配置?

P.S:我意识到此问题出现在Windows Server 2012 R2及更低版本上。

sql-server windows-server-2012-r2 sql-server-2017 sql-date-functions
1个回答
0
投票

最后,我找到了问题。此功能取决于安装了SQL Server的Windows版本。在Windows Server 2012 R2Windows 10中添加了波斯日历。

此图显示了faWindows Server 2012 R2Windows 10文化的日期格式>

New Date Format

并且此图像显示了旧版本Windows中fa文化的日期格式

Old Date Format

© www.soinside.com 2019 - 2024. All rights reserved.