Thursday, December 22, 2011

Format the system date in Dynamics AX


The following code show the dates in format like December 22, 2011

static void datesJob(Args _args)
{
    str dd, mm, yy, dt;

    dt = date2Str(systemDateGet(), 123, DateDay::Digits2, DateSeparator::Slash, DateMonth::Digits2,
           DateSeparator::Slash, DateYear::Digits4);

    dd = substr(dt, 0, 2);
    mm = substr(dt, 4, 2);
    yy = substr(dt, 7, 4);

    dt = mthname(str2int(mm)) + ' ' + dd + ', ' + yy;

    print   dt;
    pause;
}