How to calculate number of days in a Month

HI…

in dynamics navision how to calculate number of days in a month…help me urgent

Regards

Packiya

NoOfDaysInMonth :=
DATE2DMY(CALCDATE(‘CM’,DMY2DATE(01,MonthNumber,YearNumber)),1);

NoOfDaysInMonth–Type Integer

MonthNumber – Type Integer (Jan=1…Dec=12)

YearNumber-- Type Integer (e.g 2012,2013…)

/Anup

hi thnks for ur rply…but i ask how to calculate number of days in a month…

ex: jan=31 days

Feb := 28 days

Packiya

Have you tried this ?? This is giving the Month Days as per requirement.

last date of month is number of days in a month

dayofmth(endmth(12\02\2012)); - you will get number of days in this

Hi Maria,

This question is about Microsft Dynamics NAV and not AX.

Date[1] := DMY2DATE(1,IntialMonth,IntialYear);

FOR i:=2 TO LastMonth DO BEGIN

Date[i] := DMY2DATE(1,IntialMonth+1,IntialYear);

IntialMonth := IntialMonth+1;

END;

(above code is to calculate the Start Dates from an input date)

so the Difference between Date[1] and Date [2] is the number of days.

Date2 := Date[2]-1;

Still you want the Days

Days:= DATE2DMY(Date2,1);

Thats it. Let me know if you have any suggestion. This post is for future. Thanks