{"title":"System.CalcDate(Text [, Date]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-calcdate-string-date-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-calcdate-string-date-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-calcdate-string-date-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Calculates a new date that is based on a date expression and a reference date.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.CalcDate(Text [, Date]) Method","slug":"systemcalcdatetext-date-method","at":0,"chars":4562},{"level":2,"title":"Syntax","slug":"syntax","at":179,"chars":161},{"level":2,"title":"Parameters","slug":"parameters","at":340,"chars":1375},{"level":2,"title":"Return Value","slug":"return-value","at":1715,"chars":53},{"level":2,"title":"Remarks","slug":"remarks","at":1768,"chars":1138},{"level":2,"title":"Example 1","slug":"example-1","at":2906,"chars":441},{"level":2,"title":"Example 2","slug":"example-2","at":3347,"chars":1081},{"level":2,"title":"Related information","slug":"related-information","at":4428,"chars":134}],"text":"# System.CalcDate(Text [, Date]) Method\n> Version: _Available or changed with runtime version 1.0._\nCalculates a new date that is based on a date expression and a reference date.\n## Syntax\n```al\nNewDate :=   System.CalcDate(DateExpression: Text [, Date: Date])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nDateExpression\nType: ../text/text-data-type\nThe date expression can be any length. The string is interpreted from left to right with one subexpression at a time. The following rules describe the valid syntax of date expressions:\n DateExpression = [\\<Subexpression\\>][\\<Subexpression\\>][\\<Subexpression\\>]\n \\<Subexpression\\> = [\\<Sign\\>] \\<Term\\>- \\<Sign\\> = + | -\n \\<Term\\> = \\<Number\\>\\<Unit\\> | \\<Unit\\>\\<Number\\> | \\<Prefix\\>\\<Unit\\>\n \\<Number\\> = Positive integer\n \\<Unit\\> = D | WD | W | M | Q | Y (D=day, WD=weekday, W=week, M=month, Q=quarter, Y=year)\n \\<Prefix\\> = C (C=current)\nThese 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:\n 30D (30 days; corresponds to \\<Number\\>\\<Unit\\>)\n WD2 (weekday number 2; corresponds to \\<Unit\\>\\<Number\\>)\n CW (current week; corresponds to \\<Prefix\\>\\<Unit\\>)\nThe internal calendar starts on Monday and ends on Sunday. This means that Monday is weekday 1 and Sunday is weekday 7. A run-time error occurs if the syntax of DateExpression is incorrect.\n*[Optional] Date*\nType: ../date/date-data-type\nUse this optional parameter to define a reference date. The default is the current system date. If you omit this optional value, the current system date is used.\n## Return Value\nNewDate\nType: ../date/date-data-type\n## Remarks\nDateExpression can be a field or variable of type Text or Code, and it can be a field or variable of type ../dateformula/dateformula-data-type. The benefit of using a DateFormula field or variable is that the date formula becomes language independent.\nThe user can enter formulas in the currently selected language. The formula is stored in a generic format in a field or variable. When the formula must be displayed, the actual string that is displayed is converted to the currently selected language.\nFor example, if a user who has language set to ENG \\(English\\) enters the date formula \"1W+1D\" for one week and one day, then a user who has the language set to FRA \\(French\\) sees \"1S+1J,\" and a user who has the language set to ESP \\(Spanish\\) sees \"1S+1D\".\nIf a date formula is entered with \\< > delimiters surrounding it, then the date formula is stored in a generic, nonlanguage-dependent format. This makes it possible to develop date formulas that are not dependent on the currently selected language.\nFor more information about how to calculate the duration between two DateTimes, see ../duration/duration-data-type.\n## Example 1\nThis code example shows how to use the production rules that were previously described.\n```al\n<CQ+1M-10D>\n```\nThis should be interpreted as the following: current quarter + 1 month - 10 days.\nThe DateExpression is composed of the following:\n\\<Prefix>\\<Unit>\\<Sign>\\<Number>\\<Unit>\\<Sign>\\<Number>\\<Unit>\n> NOTE\n> The angle brackets \\(\\< >\\) specify that the expression is not translated, regardless of the application language.\n## Example 2\nThis example shows how to use the CalcDate method.\n```al\nvar\n    Expr1: Text[30];\n    Expr2: Text[30];\n    Expr3: Text[30];\n    RefDate: Date;\n    Date1: Date;\n    Date2: Date;\n    Date3: Date;\n    RefDateTxt: Label 'The reference date is: %1 \\\\';\n    Expr1Txt: Label 'The expression: %2 returns %3\\\\';\n    Expr2Txt: Label 'The expression: %4 returns %5\\\\';\n    Expr3Txt: Label 'The expression: %6 returns %7';\nbegin\n    Expr1 := '<CQ+1M-10D>'; // Current quarter + 1 month - 10 days\n    Expr2 := '<-WD2>'; // The last weekday no.2, (last Tuesday)\n    Expr3 := '<CM+30D>'; // Current month + 30 days\n    RefDate := 19960521D;\n    Date1 := CalcDate(Expr1, RefDate);\n    Date2 := CalcDate(Expr2, RefDate);\n    Date3 := CalcDate(Expr3, RefDate);\n    Message(RefDateTxt + Expr1Txt + Expr2Txt + Expr3Txt,\n      RefDate, Expr1, Date1, Expr2, Date2, Expr3, Date3);\nend;\n```\nThe message window displays the following text:\nThe reference date is: 05/21/96\nThe expression: CQ+1M-10D returns 07/20/96\nThe expression: -WD2 returns 05/14/96\nThe expression: CM+30D returns 06/30/96\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}