
#Date time calc how to
This example shows how to use the CALCDATE function. For more information about multilanguage capabilities with date formulas, see Developing Multilanguage-Enabled Applications. The angle brackets () specify that the expression is not translated, regardless of the application language. The DateExpression is composed of the following: This should be interpreted as the following: current quarter + 1 month - 10 days.
#Date time calc code
This code example shows how to use the production rules that were previously described. This makes it possible to develop date formulas that are not dependent on the currently selected language.įor more information about how to calculate the duration between two DateTimes, see Duration Data Type.

If a date formula is entered with delimiters surrounding it, then the date formula is stored in a generic, nonlanguage-dependent format. When the formula must be displayed, the actual string that is displayed is converted to the currently selected language.įor 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".

The formula is stored in a generic format in a field or variable. The user can enter formulas in the currently selected language. The benefit of using a DateFormula field or variable is that the date formula becomes language independent. RemarksĭateExpression can be a field or variable of type Text or Code, and it can be a field or variable of type DATEFORMULA. The date that is computed from the reference date and the date expression. If you omit this optional value, the current system date is used. Use this optional parameter to define a reference date. This means that Monday is weekday 1 and Sunday is weekday 7.Ī run-time error occurs if the syntax of DateExpression is incorrect. The internal calendar of Dynamics NAV starts on Monday and ends on Sunday. The following are some typical examples of terms: Each subexpression consists of an optional sign and a term. These production rules show that date expressions consist of zero, one, two, or three subexpressions. = D | WD | W | M | Q | Y (D=day, WD=weekday, W=week, M=month, Q=quarter, Y=year) The following rules describe the valid syntax of date expressions: The string is interpreted from left to right with one subexpression at a time. Text(Time(Value(BirthHour.Text), Value(BirthMinute.Text), Value(BirthSecond.Calculates a new date that is based on a date expression and a reference date. If a user typed 14 in a text-input control named BirthHour, 50 in a text-input control named BirthMinute, and 24 in a text-input control named BirthSecond, this function would return 02:50:24 p. If a user typed 1979 in a text-input control named HireYear, 3 in a text-input control named HireMonth, and 17 in a text-input control named HireDay, this function would return :ĭate(Value(HireYear.Text), Value(HireMonth.Text), Value(HireDay.Text)) Time (For example, 80 is interpreted as 1980.) Numbers greater than 1899 are interpreted as absolute (1980 is interpreted as 1980) numbers that range from 0 to 1899 are interpreted as relative to 1900. See the DateValue, TimeValue, and DateTimeValue functions for information about how to convert a string to a value.Īlso see working with dates and times for more information. The result has no date associated with it. The Time function converts individual Hour, Minute, and Second values to a Date/Time value.
#Date time calc plus
If Day is less than 1, the function subtracts that many days, plus 1, from the first day of the specified month.

