如何转换英文和法文日期

2021-09-10 00:00:00 sql sql-server-2005 tsql sql-server

我正在尝试在我的表格中存储格式化的显示日期.例如,我的日期是 20150621,我希望它是 2015 年 6 月 21 日和 2015 年 6 月 21 日(法语).

I am trying to store formatted display dates in my tables. For example, I have a date as 20150621 and I want it as June 21, 2015 and 21 juin 2015 (for French).

我有一个查询:convert(varchar(12),cast([datecolumn]) as datetime),107)

这输出: Jun 21,2015 ,但我需要 June 21,2015 和法语日期.

This outputs: Jun 21,2015 , but I need June 21,2015 and also French date.

我使用的是 Sql 2005,因此格式在其中不起作用.

I am using Sql 2005, so format doesn`t work in it.

推荐答案

Write as:

    SELECT DATENAME(MM, CAST([datecolumn] AS DATETIME))
       + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) 
       AS [Month DD, YYYY]
from test

Go

SET LANGUAGE French
SELECT CONVERT(VARCHAR(12),CAST(datecolumn AS DATETIME),106) as [DD MON YYYY]
from test

演示

相关文章