Returns the day of the week, week number, or year of a
Date Data
Type.
|
Number := DATE2DWY(Date, What)
|
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.
Property Value/Return Value
Type: Integer
The resulting day of the week, week number, or year.
Remarks
Example
This example shows a special case that occurs when you
use the DATE2DWY function in a week which spans two years. This
code example requires that you create the following variables and
text constants in the C/AL Globals window.
Variable name |
DataType |
InputDate
|
Date
|
DayOfWeek
|
Integer
|
WeekNumber
|
Integer
|
Year
|
Integer
|
Text constant name |
ENU value |
Text000
|
The date %1 corresponds to:\
|
Text001
|
The day of the week: %2\
|
Text002
|
The week number: %3\
|
Text003
|
The year: %4
|
|
Copy Code |
InputDate := 010109D;
DayOfWeek := DATE2DWY(InputDate, 1);
WeekNumber := DATE2DWY(InputDate, 2);
Year := DATE2DWY(InputDate, 3);
MESSAGE(Text000 + Text001 + Text002 + Text003, InputDate, DayOfWeek, WeekNumber, Year);
|
The message window displays the following:
The date 01/01/09 corresponds to:
The day of the week: 4
The week number: 1
The year: 2009
This example shows that the date 01/01/09 is regarded
as day number 4 (Thursday) in week number 1 in the year 2009.
See Also