如何将日期格式更改为法语 [英] How to change date format to french

查看:108
本文介绍了如何将日期格式更改为法语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



i有一个像20150414这样的日期格式,我想把它改成14 avril 2015,所以基本上用法语存储过程,任何人都可以告诉我,因为我认为它没有ssms的标准



任何帮助都会非常适合



谢谢

Hi All

i have a date format like 20150414 , and i want it to change it to 14 avril 2015 , so basically in french in stored procedure , anyone can tell me as i think there is no standard in ssms for it

any help would be much appriciated

Thanks

推荐答案

那是因为这是一个坏主意! :笑:



首先,你不应该把日期存储为字符串:你应该总是将它们存储为DATE或DATETIME - 而且它们没有格式,它们被存储为自任意时间点以来的微秒数。将日期存储为字符串既浪费又是PITA,因为很难对它们进行有用的比较。



其次,因为显示的格式化日期不是数据库功能 - 它确实需要在您的演示软件中完成,它可以以他的首选格式向用户呈现数据。在现代WWW世界中,假设您使用或喜欢的日期格式适合所有用户是愚蠢的:即使在任何欧洲国家的中型公司,您也会得到喜欢输入和阅读日期的用户不同的格式!



因此,更改数据库,以适当的格式存储数据,并进行转换(尽可能早地从用户输入,尽可能晚地输出)在您的演示文稿软件中,您可以访问用户首选的文化信息。
That's because it's a bad idea! :laugh:

Firstly, you shouldn't store dates as strings: you should always store them as DATE or DATETIME instead - and they don't have a format, they are stored as the number of microseconds since an arbitrary point in time. Storing dates as strings is both wasteful, and a PITA because it is very difficult to do useful comparisons on them.

Secondly, because formatting dates for display is not a database function - it really needs to be done in your presentation software instead, where it can present the data to the user in his preferred format. In the modern WWW world, it's silly to assume that the date format you use or prefer is going to suit all your users: even in a medium sized company in any European country you are going to get users who prefer to input and read dates in a different format!

So change your DB, store data in an appropriate format, and do conversions (from user input as early as possible, for output as late as possible) in your presentation software where you have access to the users preferred Cultural information.


正如Griff所说,不要将日期存储为字符串,并避免在数据库层中格式化值。 />


但是,如果您必须在数据库层中格式化日期,并且您使用的是Microsoft SQL Server 2012或更高版本,则可以使用 FORMAT 函数 [< a href =https://msdn.microsoft.com/en-GB/library/hh213505%28v=sql.1 10%29.aspxtarget =_ blanktitle =New Window> ^ ]:

As Griff said, don't store dates as strings, and avoid formatting values in the database layer.

However, if you absolutely have to format a date in the database layer, and you're using Microsoft SQL Server 2012 or later, you can use the FORMAT function[^]:
DECLARE @D date = '20150415';
SELECT FORMAT(@D, 'dd MMMM yyyy', 'fr-FR');
-- Output: 15 avril 2015


这篇关于如何将日期格式更改为法语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆