New line for every month between two dates

hay i have two dates in header tab and i have to create lines which is the difference of both date.

for example date 1= 1 jan 2013 and date 2 = 31 dec 2013, then i have to create 12 lines in line tab…

check this for date difference

http://dynamicsuser.net/forums/t/39740.aspx

Remaining part you have to insert records into lines table and refresh the child datasource

can u suggest me Remaining part

Please try to use more descriptive thread names. The whole forum is about Dynamics AX, therefore that’s not a very useful information. You can add a tag with your version of AX.

What’s your question about the remaining part? What did you manage to implement and what are struggling with?

can u give me solution of this,?

Look what Martin asked What’s your question about the remaining part? What did you manage to implement and what are struggling with?

Tell us what you need with more details please.

can u give me u r Skype ID…

for example first date id 07-10-2013 and 2nd date is 14-08-2015.

we use this code to calculate number of months bwtn dates.

months = intvNo(RentAgreementSetupHeaderTable.ToDate,RentAgreementSetupHeaderTable.FromDate , intvScale::YearMonth);

after this we get the value of monts is 22
then i have to create 22 lines in line tab.

You still haven’t wrote what’s the problem - creating the loop, inserting records, calculating dates, anything else?

The following snippet shows how to create 22 records:

int i;
YourTable table;
    
for (i = 0; i < 22; i++)
{
    table.clear();
    table.initValue();
    table.initFromSomeOtherTable(someOtherTable);
    table.Field1 = someParameter;
    table.insert();
}

If you are looking to find the number of months (source \Classes\AssetTableInterval_Month\monthDifference)

static void monthDif(Args _args)

{

TransDate fromDate = mkDate(01, 05, 2012);

TransDate toDate = systemDateGet();

real fractionStartMonth;

real fractionEndMonth;

fractionStartMonth = dayofmth(fromDate)/ dayofmth(endmth(fromDate));

fractionEndMonth = dayofmth(toDate)/ dayofmth(endmth(toDate));

//BP Deviation Documented

print any2int(roundDown((fractionEndMonth + mthofyr(toDate) + year(toDate) *12) -

//BP Deviation Documented

(fractionStartMonth + mthofyr(fromDate) + year(fromDate)*12) ,1));

pause;

}

which method we

use for this?

for what?

for inserting the rows in line tab?