What is the best/shortest method of converting XML datetime into NAV datetime?

Slawek_Guzek
Member Posts: 1,690
yyyy-MM-ddThh:mm into NAV datetime please?
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
0
Best Answers
-
NavDateTime := DotNetDateTime.Parse(DateTimeText);
That's what I've been looking forSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »@nick_robbo
Nope. NB: the format you have used is not XML. Try this:TextDateTime := FORMAT(OriginalTextDateTime, 0, 9) EVALUATE(DateTime, TextDateTime)
Yes, thanks for that.
I was about to link you to this but I see you have found it...
https://stackoverflow.com/questions/20090297/c-sharp-datetime-conversion-from-yyyy-mm-ddthhmmss-to-dd-mmm-yyyy5 -
The best/shortest method is as follows (doesn’t even require a DotNet variable)...
EVALUATE(NavDateTime,DateTimeText,9);
1
Answers
-
I'm sure it isn't the shortest or prettiest method, but it works:
GetDateFromText(DateTimeText : Text[30]) DateValue : Date DateTimeText := COPYSTR(DateTimeText,1,STRPOS(DateTimeText,'T') - 1); YearText := COPYSTR(DateTimeText,1,STRPOS(DateTimeText,'-') - 1); DateTimeText := DELSTR(DateTimeText,1,STRLEN(YearText) + 1); MonthText := COPYSTR(DateTimeText,1,STRPOS(DateTimeText,'-') - 1); DateTimeText := DELSTR(DateTimeText,1,STRLEN(MonthText) + 1); DayText := DateTimeText; EVALUATE(DateValue,DayText + '.' + MonthText + '.' + YearText); GetTimeFromText(DateTimeText : Text[30]) TimeValue : Time EVALUATE(TimeValue,COPYSTR(DateTimeText,STRPOS(DateTimeText,'T') + 1,8));
0 -
@AK hmm expected / hoped for a one-liner to be frank...
and not in form of combinig all COPYSTR/STRPOS/DELCHR into one call
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Does Evaluate work?
TextDateTime := FORMAT(OriginalTextDateTime)
EVALUATE(DateTime, TextDateTime)
0 -
@nick_robbo
Nope. NB: the format you have used is not XML. Try this:TextDateTime := FORMAT(OriginalTextDateTime, 0, 9) EVALUATE(DateTime, TextDateTime)
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
NavDateTime := DotNetDateTime.Parse(DateTimeText);
That's what I've been looking forSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »@nick_robbo
Nope. NB: the format you have used is not XML. Try this:TextDateTime := FORMAT(OriginalTextDateTime, 0, 9) EVALUATE(DateTime, TextDateTime)
Yes, thanks for that.
I was about to link you to this but I see you have found it...
https://stackoverflow.com/questions/20090297/c-sharp-datetime-conversion-from-yyyy-mm-ddthhmmss-to-dd-mmm-yyyy5 -
The best/shortest method is as follows (doesn’t even require a DotNet variable)...
EVALUATE(NavDateTime,DateTimeText,9);
1 -
The best/shortest method is as follows (doesn’t even require a DotNet variable)...
EVALUATE(NavDateTime,DateTimeText,9);
Thanks @Kishorm . THAT was exactly what I was afterSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
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