mm / dd / yyyy格式问题 [英] mm/dd/yyyy format question
问题描述
大家好,
我正在创建一个项目,在显示日期或创建日期时,应始终使用此日期格式。后端数据库是一个SQL Server,我喜欢
来了解配置服务器,sql server或程序的逻辑方式是什么
它始终处理日期为mm / dd / yyyy格式。
提前致谢。
Roy
< BLOCKQUOTE>"罗伊" < Ro*@discussions.microsoft.com> schrieb
我正在创建一个项目,当
显示日期或创建日期时,应始终使用此日期格式。后端数据库是一个SQL
服务器,我想知道配置服务器,sql服务器或程序的逻辑方式是什么,所以它始终处理日期为
mm / dd / yyyy格式。
提前致谢。
这取决于您显示和输入日期的方式。如果您手动将
DateTime转换为String,请使用格式MM \ / dd \ / yyyy。如果你使用数据绑定
控件,我不确定因为我从不使用它们。我只知道
可以用于
格式化的System.Windows.Forms.Binding.Format事件。
如果用户输入日期,并且如果你想强制使用这种输入格式,你可以使用Date.ParseExact。
关于sql server:如果你使用SqlCommands的参数,你只需设置参数的值
。 SqlCommand为你做了正确的格式化
。
参见:
http://msdn.microsoft.com/library/en...ttingtypes.asp
(特别是日期和时间格式字符串)
虽然,我更喜欢使用我的区域设置的应用程序,即
以区域格式显示和接受日期。
Armin
Roy,
除了Armin,
请注意,如果您将在北美使用您的应用程序
大陆使用此格式1/12 / 2005年意味着在加拿大获得第1名
2005年12月
如果老板确定问题,将来有一个愉快的时间
决定他们将在加拿大拥有一个客户/位置,并且无需告诉你/ b
。
Cor
我也建议使用区域设置。它使应用程序更加坚固。
我最近遇到了这个特殊问题,我正在改变使用的东西
要使用的东西区域设置
LDD
" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道
news:%2 *************** @ TK2MSFTNGP11.phx.gbl ...Roy ; < Ro*@discussions.microsoft.com> schrieb我正在创建一个项目,当
显示日期或创建日期时,应始终使用此日期格式。后端数据库是一个SQL
服务器,我想知道配置服务器,sql服务器或程序的逻辑方式是什么,所以它始终处理日期为
mm / dd / yyyy格式。
提前致谢。
这取决于您如何显示和输入日期。如果您手动将
从DateTime转换为String,请使用格式MM \ / dd \ / yyyy。如果你使用数据绑定
控件,我不确定因为我从不使用它们。我只知道有可用于
格式化的System.Windows.Forms.Binding.Format事件。
如果用户输入日期,如果你想要强制使用这种输入格式,你可以使用Date.ParseExact。
关于sql server:如果你使用SqlCommands参数,你只需设置参数的值即可。 SqlCommand为您执行正确的格式化。
另请参阅:
http://msdn.microsoft.com/library/en...ttingtypes.asp (特别是日期和时间格式字符串 ;)
虽然,我更喜欢使用我的区域设置的应用程序,即
以区域格式显示和接受日期。
Armin
Hi all,
I''m creating a project that should always use this date format when displays
the dates or create dates. The back end database is a SQL Server and I like
to know what is the logical way to configure server, sql server or program so
it always deals with date as mm/dd/yyyy format.
Thanks in advance.
Roy
"Roy" <Ro*@discussions.microsoft.com> schriebI''m creating a project that should always use this date format when
displays the dates or create dates. The back end database is a SQL
Server and I like to know what is the logical way to configure
server, sql server or program so it always deals with date as
mm/dd/yyyy format.
Thanks in advance.
It depends on how you display and enter dates. If you manually convert from
DateTime to String, use the format "MM\/dd\/yyyy". If you use databound
controls, I''m not sure because I never use them. I only know that there is
the System.Windows.Forms.Binding.Format event that can be used for
formatting.
If the user enters dates, and if you want to force this input format, you
can use Date.ParseExact.
Concerning sql server: If you use parameters with SqlCommands, you simply
set the value of the parameter. The SqlCommand does the correct formatting
for you.
See also:
http://msdn.microsoft.com/library/en...ttingtypes.asp
(especially "Date and Time Format Strings")
Though, I would prefer an application using my regional settings, i.e.
displaying and accepting the date in regional format.
Armin
Roy,
In addition to Armin,
Be aware that if you would use your application in the North America
continent where this format is used 1/12/2005 would mean in Canada 1th
December 2005
Have a pleasure time in future with correcting the problems if you boss
decide that they will have a client/location in Canada and tell nothing to
you.
Cor
I''d also suggest using the regional settings. It makes the app much more
robust.
I recently ran into this particular issue, and am in the process of changing
things to use the regional settings
LDD
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl..."Roy" <Ro*@discussions.microsoft.com> schriebI''m creating a project that should always use this date format when
displays the dates or create dates. The back end database is a SQL
Server and I like to know what is the logical way to configure
server, sql server or program so it always deals with date as
mm/dd/yyyy format.
Thanks in advance.
It depends on how you display and enter dates. If you manually convert
from DateTime to String, use the format "MM\/dd\/yyyy". If you use databound
controls, I''m not sure because I never use them. I only know that there is
the System.Windows.Forms.Binding.Format event that can be used for
formatting.
If the user enters dates, and if you want to force this input format, you
can use Date.ParseExact.
Concerning sql server: If you use parameters with SqlCommands, you simply
set the value of the parameter. The SqlCommand does the correct formatting
for you.
See also:
http://msdn.microsoft.com/library/en...ttingtypes.asp (especially "Date and Time Format Strings")
Though, I would prefer an application using my regional settings, i.e.
displaying and accepting the date in regional format.
Armin
这篇关于mm / dd / yyyy格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!