将日期设置为UTC的问题自动设置

发布于 2025-02-08 09:31:23 字数 446 浏览 1 评论 0原文

我有一个系统,可以从PostgreSQL DB中获取数据并将其写入SQL Server 2012。双方的字段名称均相同。 PostgreSQL作为SaaS解决方案的一部分交付。 (我只读取对DB的访问。)

对象是从dapper选择并交给插入器插入物的。我有几个字段是日期时间,当它们存储在SQL DB中时,它们会自动移动到UTC。我该如何停止?我需要该字段来表示当地的时间。我知道将所有内容存储在UTC中是最佳实践,但是要求在双方都具有相同的价值。

PostgreSQL中的字段类型是带有时区的时间戳,SQL Server端是DateTime2。

该应用程序使用Dapper版本2.0.123,并使用.NET Core 3.1。 (这是Windows服务。)

TLDR;从PostgreSQL提取数据并将其保存到SQL Server 2012时,日期和时间字段将自动转换为SQL Server上的UTC。我该如何停止?

I have a system that pulls data from a PostgreSQL DB and writes it to SQL Server 2012. The field names are the same on both sides. PostgreSQL is delivered as part of a SaaS solution. (I only have read access to the DB.)

The object is created from the dapper select and handed to a dapper insert. I have a couple of fields that are Date time, when they are stored in the SQL DB they are moved from BST to UTC automatically. How do I stop this? I need the field to represent the time in local time. I know storing everything in UTC is best practice but the requirements are to have the same value on each side.

The field type in PostgreSQL is TIMESTAMP WITH TIMEZONE and the SQL server side is DATETIME2.

The application is using Dapper version 2.0.123 and is using .Net Core 3.1. (It is a Windows Service.)

TLDR; When extracting data from PostgreSQL and saving it to SQL Server 2012 the date and time fields are automatically converted to UTC on the SQL Server. How do I stop this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文