我正在尝试在我的表格中存储格式化的显示日期.例如,我的日期是 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
演示
这篇关于如何转换英文和法文日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!