Ok, then it’s easy. Use the DATE2DWY function.
From the Microsoft Dynamics NAV Documentation |
---|
DATE2DWY Function (DATE) |
Returns the day of the week, week number, or year of a Date Data Type.
<br>Number := DATE2DWY(Date, What)<br> |
Parameters
- Date
Type: date
The input date
- What
-
Type: integer
Specifies what the function returns. The valid options are 1, 2, and 3.
The value 1 corresponds to day of the week (1-7, Monday = 1).
The value 2 corresponds to week number (1-53).
The value 3 corresponds to year.
Type: integer
The resulting day of the week, week number, or year.
Remarks
If the input date to the DATE2DWY function is in a week which spans two years, the DATE2DWY function computes the output year as the year of the first day in the week. This scenario is shown in the following code example.
Example
Copy Code
D := 010194D;
DayOfWeek := DATE2DWY(D, 1);
WeekNumber := DATE2DWY(D, 2);
Year := DATE2DWY(D, 3);
MESSAGE(Text000 + Text001 + Text002 + Text003, D, DayOfWeek, WeekNumber, Year);