I can't evaluate a DateTime value

isabtogumon
Member Posts: 50
Hi,
I'm trying to evaluate a value, however I am getting the following error:
The value "2021-02-16T09:26:36.953" can't be evaluated into type DateTime.
With what method can I solve the problem?
I'm trying to evaluate a value, however I am getting the following error:
The value "2021-02-16T09:26:36.953" can't be evaluated into type DateTime.
With what method can I solve the problem?
0
Best Answer
-
I solved the problem, I did it this way
txtDate := '2021-02-16T09:26:36.953'; txtNewDate := CopyStr(txtDate, 1, 4) + '-' + CopyStr(txtDate, 6, 2) + '-' + CopyStr(txtDate, 9, 2) + ' ' + CopyStr(txtDate, 12, 2) + ':' + CopyStr(txtDate, 15, 2) + ':' + CopyStr(txtDate, 18, 2); Evaluate(formatDate, txtNewDate); Data.DateMov := formatDate;
Thank you for your answers0
Answers
-
DateTime := CREATEDATETIME(Date, Time)
or
NewDateTime := ROUNDDATETIME(Datetime [, Precision][, Direction])
or
*this one below is to just get the date from the value you indicated
Date := DT2DATE(Datetime)
not sure what you are trying to do or evaluate it to...
0 -
Evaluate(MyDateTime,'2021-02-16T09:26:36.953',9); // Note the ,9 parameter0
-
Hi @CodeViper, I want to convert text to date and time, date value that I get in text format through a variable, which in turn I get from an element of an XML.
Evaluate(varDateTime, (xmlNod.AsXmlElement().InnerText),9); Data.DateTime := varDateTime;
I tried the above but it is not accurate since when converting this date "2021-02-16T09: 26: 36.953" the method returns this "02/16/2021 03:26 AM". Is there a way to segment the text to get the precise time?
0 -
Hi @lynge,
I tried your suggestion, however the method does not return the precise time. I got this value: "02/16/2021 03:26 am"
Is there any other method to convert from this value "2021-02-16T09: 26: 36.953" to this value "02/16/2021 09:26:36 a. m.", since the first value is text format?
0 -
I solved the problem, I did it this way
txtDate := '2021-02-16T09:26:36.953'; txtNewDate := CopyStr(txtDate, 1, 4) + '-' + CopyStr(txtDate, 6, 2) + '-' + CopyStr(txtDate, 9, 2) + ' ' + CopyStr(txtDate, 12, 2) + ':' + CopyStr(txtDate, 15, 2) + ':' + CopyStr(txtDate, 18, 2); Evaluate(formatDate, txtNewDate); Data.DateMov := formatDate;
Thank you for your answers0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions