Business Central working with dates
I want to report some information collected from several parts on the calculation of dates through dateformula
and calcdate, since they are very used. It could be useful, especially for those new to Business Central.
C = Current
D = Day
W = Week
M = Month
Q = Quarter
Y = Year
CD = Current Day
CW = Current week
CM = Current month
CM -> last date of the current month
<-CM> -> first date of the current month
+D -> example to the first date of next month
-1M -> example going back one month
10D = 10 days from today
2W = 2 weeks from today
D10 = The next 10th day of a month
WD4 = The next 4th day of a week (Thursday)
CM+10D = Current month + 10 days
-1Y = 1 year ago from today
Calculation example – firts & last days
First day of the month: <-CM>
Last day of the month: <+CM>
Last day of next month: <+1M+CM>
NewDate := CALCDATE(DateExpression [, Date])
DateExpression = 
= + | –
= | |
= Positive integer
= D | WD | W | M | Q | Y (D=day, WD=weekday, W=week, M=month, Q=quarter, Y=year)
= C (C=current)
These production rules show that date expressions consist of zero, one, two, or three subexpressions.
Each subexpression consists of an optional sign and a term.
The following are some typical examples of terms:
30D (30 days; corresponds to )
WD2 (weekday number 2; corresponds to )
CW (current week; corresponds to )
The internal calendar of Dynamics NAV starts on Monday and ends on Sunday. This means that Monday is weekday 1 and Sunday is weekday 7.
Expr1 := ”; // Current quarter + 1 month – 10 days
Expr2 := ‘<-WD2>’; // The last weekday no.2, (last Tuesday)
Expr3 := ”; // Current month + 30 days
RefDate := 052196D;
Date1 := CALCDATE(Expr1, RefDate);
Date2 := CALCDATE(Expr2, RefDate);
Date3 := CALCDATE(Expr3, RefDate);
MESSAGE(Text000 + Text001 + Text002 + Text003,
RefDate, Expr1, Date1, Expr2, Date2, Expr3, Date3);
codeunit 50001 “CheckEndofMonthfromDate”
procedure CheckEndMonth(pDate: Date): Boolean
ClosingDate := CALCDATE(”, pDate);
IF pDate = ClosingDate THEN
One thought on “Business Central working with dates”
Good day Roberto
Thank you so much for this blog and informative post – it really made sense of the calculations as we are new to BC and it was a constant source of misunderstandings and confusion.
Could I ask you how to correct Posted documents after I updated payment terms?
It does not seem to have applied my changes after correcting them.
Eugene – South Africa
Comments are closed.