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

I have the same question (0)
  • Verified answer
    Roger Larsson Profile Picture
    25 on at

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

  • Suggested answer
    pankaj.k Profile Picture
    994 on at

    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

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

    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;

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