Hi Folks,
I come though a requirement where I need to manipulate on “FromDate” and “ToDate”. When user enter these value through a dialog box, user can select any day from month for eg.
From Date: June 6, 2015
To Date: August 20, 2015
And to perform some action on Financial stuff we may need to consider the whole month like
from June 1, 2015 to August 31, 2015
You can fetch this month range in your x++ code, here is a sample code, try it…
static void theAxapta_MonthRange(Args _args)
{
DialogField dialogStartDate, dialogEndDate;
Dialog dialog = new Dialog("Month range");
TransDate fromDate, todate;
dialogStartDate = dialog.addField(extendedTypeStr(TransDate));
dialogEndDate = dialog.addField(extendedTypeStr(TransDate));
dialogStartDate.label("From Date");
dialogEndDate.label("To Date");
if(dialog.run())
{
fromDate = mkDate(1, mthOfYr(dialogStartDate.value()), year(dialogStartDate.value()));
toDate = (mkDate(1, (mthOfYr(dialogEndDate.value()) + 1), year(dialogEndDate.value())) - 1);
info(strFmt("Start Month %1", fromDate));
info(strFmt("End Month %1", todate));
}
}
Output:
In case of any suggestion and query, feel free to drop as a comment.
-Harry
I come though a requirement where I need to manipulate on “FromDate” and “ToDate”. When user enter these value through a dialog box, user can select any day from month for eg.
From Date: June 6, 2015
To Date: August 20, 2015
And to perform some action on Financial stuff we may need to consider the whole month like
from June 1, 2015 to August 31, 2015
You can fetch this month range in your x++ code, here is a sample code, try it…
static void theAxapta_MonthRange(Args _args)
{
DialogField dialogStartDate, dialogEndDate;
Dialog dialog = new Dialog("Month range");
TransDate fromDate, todate;
dialogStartDate = dialog.addField(extendedTypeStr(TransDate));
dialogEndDate = dialog.addField(extendedTypeStr(TransDate));
dialogStartDate.label("From Date");
dialogEndDate.label("To Date");
if(dialog.run())
{
fromDate = mkDate(1, mthOfYr(dialogStartDate.value()), year(dialogStartDate.value()));
toDate = (mkDate(1, (mthOfYr(dialogEndDate.value()) + 1), year(dialogEndDate.value())) - 1);
info(strFmt("Start Month %1", fromDate));
info(strFmt("End Month %1", todate));
}
}
Output:
In case of any suggestion and query, feel free to drop as a comment.
-Harry
No comments:
Post a Comment
Thanks