web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Evaluating date string of any date format into current system's date format in D365 Business Central

(0) ShareShare
ReportReport
Posted on by 241

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

pastedimage1659253705710v1.png


Actually, I guess, system is accepting only 1 specific format that is selected in page 'My Stettings'

pastedimage1659253720301v2.png


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.

pastedimage1659253741683v3.png


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.

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    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.

    docs.microsoft.com/.../evaluate-function

  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    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

    community.dynamics.com/.../using-data-exchange-definitions-and-transformation-rules-to-change-date-formats

    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,

  • Suggested answer
    YUN ZHU Profile Picture
    95,748 Super User 2025 Season 2 on at

    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

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-split-list%5Btext%5D-method

    https://yzhums.com/9273/

    System.DMY2Date(Integer [, Integer] [, Integer]) Method

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-dmy2date-method

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    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;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,066

#2
YUN ZHU Profile Picture

YUN ZHU 658 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 595

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans