how to convert date in English and French

邮差的信 提交于 2019-12-14 04:08:22

问题


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).

I have a query: convert(varchar(12),cast([datecolumn]) as datetime),107)

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

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


回答1:


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

DEMO




回答2:


You can set the Language to French and then run your query. Something like this

SET LANGUAGE us_english
SELECT CONVERT(VARCHAR(12),CAST('2015-01-01' AS DATETIME),107)

SET LANGUAGE French
SELECT CONVERT(VARCHAR(12),CAST('2015-01-01' AS DATETIME),107)


来源:https://stackoverflow.com/questions/29773908/how-to-convert-date-in-english-and-french

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