数据帧被源数据偏移-1天

发布于 2025-01-22 10:00:50 字数 1117 浏览 6 评论 0原文

我正在使用连接器查询Dynamics 365 Business Central中的一些表,当我查看数据框时,所有日期都被抵消到-1天。

我生成了一个logfile,以作为一个特定的发票作为示例,在logfile中,我看到了“ 2022-04-01”的正确posting_date,并且查询成功完成了与我在业务百分点中看到的内容相匹配的正确数据。

然后,当我去查看标头或将数据框加载到我的PostgreSQL数据库时,它显示为“ 2022-03-31”。有人对这里可能发生的事情有任何想法吗?在我尝试查看我的数据框架之前,所有记录都显示正确的日期-1。

import pandas as pd
from sqlalchemy import create_engine

engine = create_engine("d365businesscentral:///?InitiateOAuth=GETANDREFRESH;company=[company name];logfile=[logfile location];verbosity=3;timeout=0;OrganizationUrl=https://api.businesscentral.dynamics.com/v2.0/[key]/[environment]/ODataV4")

df = pd.read_sql("""
    SELECT
    Posting_Date
    FROM Posted_Sales_Invoice_Lines
    where Document_No = 'PS-INV153588'
    ;""", engine)

print(df.head(5))
  Posting_Date
0   2022-03-31
1   2022-03-31
2   2022-03-31
3   2022-03-31
4   2022-03-31
[Finished in 8.805s]

I am using a connector to query some tables in Dynamics 365 Business Central and when I view my dataframe all of my dates are offset by -1 days.

I generated a logfile for a specific invoice to use as an example, and in the logfile, I see the correct Posting_Date of "2022-04-01" and the query is completed successfully with the correct data that matches what I see in Business Cental.

Then, when I go to view the header, or load the dataframe to my PostgreSQL database, it shows as "2022-03-31." Anyone have any ideas on what might be going on here? Everything seems to look fine until I try to view my dataframe, where all records display the correct date -1.

enter image description here

import pandas as pd
from sqlalchemy import create_engine

engine = create_engine("d365businesscentral:///?InitiateOAuth=GETANDREFRESH;company=[company name];logfile=[logfile location];verbosity=3;timeout=0;OrganizationUrl=https://api.businesscentral.dynamics.com/v2.0/[key]/[environment]/ODataV4")

df = pd.read_sql("""
    SELECT
    Posting_Date
    FROM Posted_Sales_Invoice_Lines
    where Document_No = 'PS-INV153588'
    ;""", engine)

print(df.head(5))
  Posting_Date
0   2022-03-31
1   2022-03-31
2   2022-03-31
3   2022-03-31
4   2022-03-31
[Finished in 8.805s]

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

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

发布评论

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

评论(1

錯遇了你 2025-01-29 10:00:50

我不熟悉PostgreSQL数据库和数据范围。

但是,Business Central存储DateTimes在数据库中作为UTC时间戳,我想可以解释偏移量,因为您在阅读数据时将PST用作时区。

日期还存储为dateTime,但设置为00:00:00

I am not familiar with PostgreSQL databases and dataframes.

However Business Central stores DateTimes in the database as UTC timestamps, which I guess could explain the offset, given that you are using PST as the timezone when reading the data.

Dates are also stored as DateTime but with the time set to 00:00:00.

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