Hello,
I'm experiencing an issue with my extension that creates new purchase invoices by reading from an Excel sheet. The date that gets uploaded to Business Central is always one day less than the exact date in the Excel sheet.
For example, if the date in the Excel sheet is 3/14/2024, it gets stored as 3/13/2024 in Business Central.
Here's the code I'm using to upload the date:
Evaluate(PurchHeaderRec."Posting Date", DelChr(GetText(Buffer, RowNo, 6), '<'));//mmddyyyy
I've tried debugging the code by extracting the date components using Date2DMY and reassembling the date using DMY2Date, but the issue persists:
Evaluate(PostingDate, DelChr(GetText(Buffer, RowNo, 6), '<'));
Month := Date2DMY(PostingDate, 1);
Day := Date2DMY(PostingDate, 2);
Year := Date2DMY(PostingDate, 3);
PurchHeaderRec."Posting Date" := DMY2Date(Day, Month, Year);
Has anyone else experienced this issue, and if so, how did you resolve it? I'd appreciate any help or guidance on this matter.