Hi,
Hope you all are doing well. In Business Central, I'm receiving dates from third party application. Date's format is based upon the region/language or user. For example d/M/yyyy, d-M-yyyy, M/d/yyyy, M-d-yyyy, d.M.yyyy, M.d.yyyy etc.
After receiving date in text from 3rd part app when I try to evaluate it into type Date Business Central throws an error that '28.1.2021.' can not be evaluated into type Date, '28-1-2021' can not be evaluated into type Date etc. Let's say date I received is '28/1/2021'. System gives an error gives an error that '28/1/2021' can not be evaluated into type Date
Actually, I guess, system is accepting only 1 specific format that is selected in page 'My Stettings'
In page My Settings if date format is d/M/yyyy and the format I'm receiving from 3rd party app is also the same then this code doesn't throw any error.
If in My Settings Page date format is M/d/yyyy, d.M.yyyy etc and the format I'm receiving from 3rd party app is d-M-yyyy or any other than the format selected on My Settings page, then this AL Code doesn't work.
Is there any way to get current system's date format and evaluating the received date string (having any format) into date type?
Answers will be highly appreciated. Thanks for reading.
Hi,
You can try below code to create your Date from the string you are receiving.
docs.microsoft.com/.../system-dmy2date-method
var
Day: Integer;
Month: Integer;
Year: Integer;
OutputDate: Date;
Text000: Label "Day number %1, month number %2, and year number %3 corresponds to the date %4.";
begin
Day := 17;
Month := 2;
Year := 2014;
OutputDate := DMY2Date(Day, Month, Year);
Message(Text000, Day, Month, Year, OutputDate);
end;
Hi, I think you can split it first and then recreate the date in BC using the method below.
Text.Split(List of [Text]) Method
System.DMY2Date(Integer [, Integer] [, Integer]) Method
Hope this helps.
Thanks.
ZHU
Hi Javed,
You can setup a data exchange definition and transformation rules that might help.
docs.microsoft.com/.../across-how-to-set-up-data-exchange-definitions
If you find this useful please give it a like or verify the answer. By this way you can help other members know that the topic has been answered. Have a nice day. Thank you.
Cheers,
Maybe you can try to add ,9 after your evaluate statement. If the date you receive is in xml format.
That is the first thing i would try.
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156