Hi,
I am using the Excel Buffer functions to import data in NAV from an Excel Spreadsheet. The functions are ReadSheet and ParseCellValue.
The issue I am finding is that it reads the date column and somehow it always ends up 1 day earlier than the actual date. So if I have in Excel 05/08/2012 it will bring in 05/07/2012. I was using 2013 but just installed a standard 2013 R2 and I see the same issue there.
The Enumerator from ReadSheet seems to read the date value as that integer weird value (in this example 41037). ParseCellValue seems to take that value (which when put in Excel and then formatted to date does give me 05/08/12) and then uses a .NET control (System.DateTime.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') to convert that into a DateTime. At that point it seems it becomes 05/07/12 08 PM (no idea how or why). ](*,)
So obviously that ends up being 05/07/12 instead of 05/08.
I have replicated this behavior on client's server, my laptop and on a brand new cloud VM with 2013 R2.
Has anyone else seen this problem?
Apathy is on the rise but nobody seems to care.
0
Comments
Got a theory for why it's happening.
Seems like .net treats dates as date times.
Next, it does something to handle the time zone. since the "raw date" is at midnight, any adjustment for the time zone will set it back to the previous day.
- Reinhard
It does make a lot of sense. But this is pure standard NAV code ... Am I really the first to use this function with dates? Or am I the only one on the "wrong" timezone? :?
I used a clients file as well as one I created myself from scratch. So I don't think it is something in the spreadsheet.
As for the obsolete automation, this is a similar comment as Reinhard. In my opinion it probably is a bug but it is the same bug in 2013 R2 as well so I would have thought someone would have noticed this by now.
In those instances it was myself using a .net control, so I wasn't "blaming" NAV. But since this is part of the standard NAV code now we can blame MSFT
In general I have been avoiding using the excel buffer since it was slow, although that seems to be much better now...
One way you can resolve it is by adding 8 or 9 hours back to the date time in the function. Or there's probably a generic way to fix it based on the current time zone settings, but that's one work-around.
But, ultimately, ideally something somewhere would be changed where .net recognizes that NAV is passing "just" a date to which time zone rules do not apply. It's no good to have dates be changing unpredictably during standard operations... (if my theory is correct )
Hi,
Facing the same problem in a BC18 and wanted to try this solution.
So I created this subscriber and added the above code. just not sure where the DayUnit comes from, or what it is.
TempExcelBuffer.OpenBookStream(IStream, SheetName);
TempExcelBuffer.SetReadDateTimeInUtcDate(true);
TempExcelBuffer.ReadSheet();
worked for me in BC SaaS
This is correct, if it works.
Thanks.