X++ code to know startDate, endDate, total number of days and remaining days for given date in AX2012
Views (4324)
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:

Like
Report
*This post is locked for comments