Returns a Date data type that is based on a week day, a week,
and a year.
The input week in this example 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 |
DayOfWeek
|
Integer
|
Week
|
Integer
|
Year
|
Integer
|
OutputDate
|
Date
|
Text constant name |
ENU value |
Text000
|
Day %1 of week %2 in the year %3 is the date %4.
|
|
Copy Code |
DayOfWeek := 1;
Week := 1;
Year := 2009;
OutputDate := DWY2DATE(DayOfWeek, Week, Year);
MESSAGE(Text000, DayOfWeek, Week, Year, OutputDate);
|
On a computer with the regional format set to English
(United States), the message window displays the following:
Day 1 of week 1 in the year 2009 is the date:
12/29/08.
The example shows that the 1st day of the week in the
1st week of the year 2009 is regarded as the date December 29,
2008. The first week of the year 2009 is the first week that has
four or more days in the year 2009. That week begins on Monday,
December 28, 2008, and ends on Sunday, January 4, 2009.
The input week in this example spans two years. This
code example requires that you create the following variables and
text constants in the C/AL Globals window.
Variable name |
Data type |
DayOfWeek
|
Integer
|
Week
|
Integer
|
Year
|
Integer
|
OutputDate
|
Date
|
Text constant |
ENU value |
Text000
|
Day %1 of week %2 in the year %3 is the date %4.
|
|
Copy Code |
DayOfWeek := 1;
Week := 1;
Year := 2010;
OutputDate := DWY2DATE(DayOfWeek, Week, Year);
MESSAGE(Text000, DayOfWeek, Week, Year, OutputDate);
|
On a computer with the regional format set to English
(United States), the message window displays the following:
Day 1 of week 1 in the year 2010 is the date:
01/04/10.
The example shows that the 1st day of the week in the
1st week of the year 2010 is regarded as the date January 4, 2010.
The first week of the year 2010 is the first week that has four or
more days in the year 2010. That week begins on Monday, January 4,
2010, and ends on Sunday, January 10, 2010.
This example shows how to use the DWY2DATE function
without specifying the optional Year
parameter. The output in this example depends on the day on which
you run the code. This code example requires that you create the
following variables and text constants in the C/AL Globals
window.
Variable name |
DataType |
DayOfWeek
|
Integer
|
Week
|
Integer
|
OutputDate
|
Date
|
Text constant |
ENU value |
Text000
|
Day %1 of week %2 is the date %3.
|
|
Copy Code |
DayOfWeek := 1;
Week := 1;
OutputDate := DWY2DATE(DayOfWeek, Week);
MESSAGE(Text000, DayOfWeek, Week, OutputDate);
|
On a computer with the regional format set to English
(United States), if you ran the code on January 1, 2009, then the
message window displays the following:
Day 1 of week 1 is the date: 12/29/08.
If you do not specify the year, then the year of the
current week is used. On January 1, 2009, the current week is the
week that begins on December 29, 2008 and ends on January 4, 2009.
This week has four days in 2009 so the year of the current week is
2009. The 1st day of the first week of 2009 is 12/29/08.
On a computer with the regional format set to English
(United States), if you ran the code on January 1, 2010, then the
message window displays the following:
Day 1 of week 1 is the date: 12/29/08.
On January 1, 2010, the current week is the week that
begins on December 28, 2009 and ends on January 3, 2009. This week
has four days in 2009 so the year of the current week is 2009. The
1st day of the first week of 2009 is 12/29/08.