Wednesday, 23 May 2012

How to set minimum/empty, maximum date for date control in AX.

This job will explain how to set different operations on date conrol in AX using Global class:

static void GlobalClass(Args _args)
{
    Date    newDate;
    ;

    //Normal Dates
    info("Normal Dates:");

    //Get's today's date.
    info(strfmt('%1', today()));

    //Get's minimum/empty date (i.e. 1/1/1900).
    //Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
    //database field you will see 1/1/1900 set in the date control.
    info(strfmt('%1', Global::dateNull()));

    //Get's maximum date (i.e. 12/31/2154).
    info(strfmt('%1', Global::dateMax()));

    //How to add 2 months in date
    newDate = Global::dateMthFwd(today(), 2);
    info(strfmt('%1', newDate));
}

Output:

1 comment: