且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我想转换日期时间格式

更新时间:2023-11-29 12:15:52

尝试一下:
Try this:
SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]


转换DateTime [ ^ ]

转换DateTime [
Convert DateTime[^]

Convert DateTime[^]


您在数据库中的格式不是特定于文化的.特定于区域性的是对字符串的转换.如果您更改区域性,那么您将更改DataTime的格式.您需要做的就是改变文化.如果您将文化更改为美国,那么您将始终使用dd/mm/yy,而对于法国,它将是
Your format in the database is not culture specific. It is the conversion to a string that is culture specific. If you change the culture, then you change the format of the DataTime. What you need to do is change the culture. If you change the culture to US, then you will always be in dd/mm/yy, for France it would be
// C#
// Put the using statements at the beginning of the code module
using System.Threading;
using System.Globalization;
// Put the following code before InitializeComponent()
// Sets the culture to French (France)
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
// Sets the UI culture to French (France)
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");



只需更改为"zh-CN"



Just change to "en-US"