web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

X++ code to know startDate, endDate, total number of days and remaining days for given date in AX2012

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

Below job helps us to know the startDate, EndDate, total number of days and remaining days in the month for the given date in Ax 2012.

static void CG_Days(Args _args)
{
    int FromDays, ToDays;

    info(strFmt("Today date is %1", today()));    
    
    // Displays start date of the month for the given date.
    info(strFmt("Start date is %1 for the month of %2", date2str(DateStartMth(Today()),213,2,4,2,4,4), mthName(mthOfYr(today()))));

    // Displays end date of the month for the given date.
    info(strFmt("End date is %1 for the month of %2", date2str(endmth(Today()),213,2,4,2,4,4), mthName(mthOfYr(today()))));

    // Displays total number of days in the month for the given date
    FromDays = date2num(DateStartMth(today()));
    todays = date2num(endmth(today()));
    info(strFmt("There are total %1 days in month %2", (ToDays+1) - FromDays, mthName(mthOfYr(today()))));

    // Displays remaining number of days in the month for the given date
    FromDays = date2num(DateStartMth(today()));
    todays = date2num(today());
    info(strFmt("%1 days are remaining in the month of %2", (ToDays+1) - FromDays, mthName(mthOfYr(today()))));
}

Output:

2656.DaysOutput.png

Comments

*This post is locked for comments