SQL Server 2005 是否自动将时间字段转换为 UTC? 有ADO.Net吗?

发布于 2024-07-25 21:31:55 字数 332 浏览 3 评论 0原文

我正在使用 Visual Studio 2008。我正在使用 .xsd/tableadapters 来访问 SQL Server 2005 数据库。 我的一张表有一个日期时间字段。 当一条记录插入表中时,时间会自动转换为UTC时间,这样就可以了。 我只是想知道那件事发生在哪里。 是 SQL Server 进行转换还是 .Net 进行转换? 我在表列中找不到允许您将其设置为 UTC 的属性。 我错过了什么?

我正在使用.Net 3.5。 System.DateTime 数据类型是否自动使用 UTC? 当我插入表时,我尝试使用 ToUniversalTime 方法,时间与我不使用它时的时间相同。

I'm using Visual Studio 2008. I'm using an .xsd/tableadapters to access a SQL Server 2005 database. One of my tables has a DateTime field. When a record is inserted into the table, the time is automatically converted to the UTC time, which is fine. I just want to know where that takes place. Does SQL Server do the conversion or is .Net doing it? I couldn't find a property in my table column that allows you to set it to UTC. Did I miss something?

I'm using .Net 3.5. Does the System.DateTime datatype automatically use UTC? I tried using the ToUniversalTime method when I insert into my table and the time is the same as when I don't use it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦中楼上月下 2024-08-01 21:31:55

这是.NET。

要进行验证,请启动 SQL Profiler 跟踪并检查通过网络发送的值。

[顺便说一句,SQL Server 2008 具有用于 UTC 感知日期和时间的 datetimeoffset 数据类型。]

It's .NET.

To verify, start a SQL Profiler trace and examine the values sent across the wire.

[BTW, SQL Server 2008 has the datetimeoffset data type for UTC aware date and times.]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文