Options

Number of month

bassoumabassouma Member Posts: 12
edited 2014-06-19 in NAV Three Tier
Hello,

I want to calculate number of month from a period.
For example:start day=01/02/13 period =2Y(dateformula)
so how can i calculate the number of month for this period
The result shoud be 24 moth.

Thanks

Comments

  • Options
    majormarcell1988majormarcell1988 Member Posts: 20
    Hi,

    You might want to look at the Date table (you can only see it if you create a page/form), filtered by month and period start and end. This might give you what you need.

    Marcell
  • Options
    jglathejglathe Member Posts: 639
    How about DATE2DMY(MyDate,2) ?
  • Options
    einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I think Jens' idea leads you on the right track. The only thing you need to consider is that it could be different years. Maybe something like this...?
    RefDate := CALCDATE('<2Y>',StartDate);
    NoOfMonths := (DATE2DMY(StartDate,3) - DATE2DMY(RefDate,3)) * 12;
    NoOfMonths += (DATE2DMY(StartDate,2) - DATE2DMY(RefDate,2));
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • Options
    kinekine Member Posts: 12,562
    Hi,

    You might want to look at the Date table (you can only see it if you create a page/form), filtered by month and period start and end. This might give you what you need.

    Marcell

    This is best idea. Set the period to month, filter start and end (depends on you if you want to count the months which are not full or only the full months in the period), and the result is Date.Count... easy and fast...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.