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...
Answered

DateTime --> datatype

(0) ShareShare
ReportReport
Posted on by

I am trying to import a txt file and the data is    2005-02-09 13:30:36.493000000 and iam using datatype as datetime and iam getting error ---> "The date is not valid".

what can i do in this case is this region issue or anything else!!

  • Suggested answer
    Nitin Verma Profile Picture
    21,384 Moderator on at
    RE: DateTime --> datatype

    Hi,

    You can try below code

     var
            DTTextValue: Text;
            newTime: Time;
            newDateYear: Integer;
            newDatemonth: Integer;
            newDateDay: Integer;
            NewDate: Date;
        begin
            DTTextValue := '2005-02-09 13:30:36.493000000';
            EVALUATE(newTime, COPYSTR(DTTextValue, 12, 11));
            EVALUATE(newDateYear, COPYSTR(DTTextValue, 1, 4));
            EVALUATE(newDatemonth, COPYSTR(DTTextValue, 6, 2));
            EVALUATE(newDateDay, COPYSTR(DTTextValue, 9, 2));
            NewDate := DMY2DATE(newDateDay, newDatemonth, newDateYear);
            MESSAGE('%1..%2', NewDate, newTime);
        end;
  • Suggested answer
    pankaj.k Profile Picture
    970 on at
    RE: DateTime --> datatype

    Hi 

    you need to  Remove Red marked value because its take only 3diget  for millisecond 2005-02-09 13:30:36.493000000   

    Please check URL :  https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datetime/datetime-data-type

  • Verified answer
    Roger Larsson Profile Picture
    25 on at
    RE: DateTime --> datatype

    Import as text, the evaluate into DateTime using XML-format (9).

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,758 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans