数据帧被源数据偏移-1天
我正在使用连接器查询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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不熟悉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 to00:00:00
.