AX / D365FO – str2date Function

Use the following values to specify the positions of the day, month, and year in the _sequence parameter:

  • day: 1
  • month: 2
  • year: 3

For example, if the sequence in the string is month, year, then day, the _sequence parameter must be 231.

A zero date is returned if the input parameters specify an invalid date. The following two examples specify an invalid date:

  • str2Date(“31/12/44”, 123) // Year must be four digits to reach the minimum of January 1 1901.
  • str2Date(“31/12/2044”, 213) // 213 means the month occurs first in the string, but 31 cannot be a month.
static void str2DateExample(Args _arg)
    {
        date d;
        ;
        d = str2Date("22/11/2007", 123);
        print d;
        pause;
    }

Leave a comment