简体   繁体   English

datetimeoffset.datetime问题?

[英]datetimeoffset.datetime issues ?

when I pass the datetimeoffset.datetime to a SQL server stored procedure, the result get the month and date wrong way around. 当我将datetimeoffset.datetime传递给SQL Server存储过程时,结果错误地获得了月份和日期。

Eg when I pass 11/12/2012, the result became 12/11/2012. 例如,当我通过2012年11月12日时,结果变为2012年12月11日。 So 11th of December was changed to twelveth of November. 因此,12月11日更改为11月12日。

Is anything I can do to find the problem? 我能做些什么来发现问题吗?

In short: it might be because of culture settings that you need to check in your C# code and SQL Server. 简而言之:可能是由于区域性设置导致您需要签入C#代码和SQL Server。 In Europe and US the date formatting are quit different. 在欧洲和美国,日期格式不同。

For example: us default date formatting is "mm/dd/yyyy", while EU is "dd/mm/yyyy" 例如:我们的默认日期格式为“ mm / dd / yyyy”,而欧盟为“ dd / mm / yyyy”

Here is a post that directly address this culture settings in C# - How can I get date and time formats based on Culture Info? 这是直接在C#中解决此文化设置的帖子- 如何获取基于“文化信息”的日期和时间格式?

在您的存储过程中,请确定您必须使用强制转换或隐蔽格式对其进行格式化,以阅读此有关强制转换日期时间类型和格式的链接http://msdn.microsoft.com/zh-cn/library/aa226054%28SQL.80%29.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM