#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Options

# Number of month

Member Posts: 12
edited 2014-06-19
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

• Options
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
Member Posts: 639
• Options
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
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.