Some developer may want to know, How to pick the number of intervals between two dates? So here is built-in function used in AX
Microsoft Dynamics AX has a function called “intvNo”. It lets you choose an interval scale and gives you the result. Let’s take a look at below example:
static void getIntvBetweenMth(Args _args){ date fromDate = str2Date("10/20/2015", 213); date toDate = str2Date("12/15/2015", 213); info(strFmt("%1", intvNo(toDate, fromDate, intvScale::YearMonth)));}That will give us the interval counted in months which is 2.
You can also choose another scales:
static void getIntvBetweenMth(Args _args){
date fromDate = str2Date("10/20/2014", 213); date toDate = str2Date("12/15/2015", 213); // Days info(strFmt("Day(s): %1", intvNo(toDate, fromDate, intvScale::YearMonthDay))); // Months info(strFmt("Month(s): %1", intvNo(toDate, fromDate, intvScale::YearMonth))); // Years info(strFmt("Year(s): %1", intvNo(toDate, fromDate, intvScale::Year)));}
Days(s): 421
Month(s): 14
Year(s): 1
Please check MSDN for another scales, parameters descriptions and full reference:
Comments
Post a Comment