ISO 8601 Datetime Format

RemcoRemco Member Posts: 81
Hi,

I receive an datetime in an ISO8601 format (2011-12-16T15:08:02Z).
I want to import this datetime in NAV and split it up to a Date and Time field.
Any ideas how to do this?

According to the NAV Help function of the format property NAV can handle this <Standard Format,9>

Comments

  • DuikmeesterDuikmeester Member Posts: 308
    MyText := '2011-12-16T15:08:02Z';
    
    MyTextDate :=
      COPYSTR(MyText,9,2) + '-' +
      COPYSTR(MyText,6,2) + '-' +
      COPYSTR(MyText,1,4);
    
    MyTextTime :=
      COPYSTR(MyText,12,8);
    
    EVALUATE(MyDate,MyTextDate);
    EVALUATE(MyTime,MyTextTime);
    
  • kinekine Member Posts: 12,562
    Depends on which way you are importing the data. If as part of XML, it will work automatically, if you are assigning them into DateTime variable (you can than split them to date and time by standard functions DT2Date and DT2Time). If you are importing them through different way, you need to parse it. NAV is able to "generate" this string through the format, but I am not sure if you can EVALUATE it to DateTime variable automatically (may be yes).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • vaprogvaprog Member Posts: 1,141
    Try with
    EVALUATE(dt,'2011-12-16T15:08:02Z',9);
    
    Where dt a DateTime variable. (Note the third parameter to EVALUATE.)
  • RemcoRemco Member Posts: 81
    Thanks, the last suggestion works!!
Sign In or Register to comment.