public static DateTime CalculateFloatingDate(
int year,
int month,
DayOccurrence occur,
DayOfWeek dowDay,
int offset
)
Public Shared Function CalculateFloatingDate (
year As Integer,
month As Integer,
occur As DayOccurrence,
dowDay As DayOfWeek,
offset As Integer
) As DateTime
public:
static DateTime CalculateFloatingDate(
int year,
int month,
DayOccurrence occur,
DayOfWeek dowDay,
int offset
)
static member CalculateFloatingDate :
year : int *
month : int *
occur : DayOccurrence *
dowDay : DayOfWeek *
offset : int -> DateTime
Use a positive value for the nOffset parameter for a number of days after the calculated date or a negative number for a number of days before the calculated date.
Normally, this value will be zero so that the calculated date is the actual date returned. However, in cases where a date is calculated in terms of the number of days before or after a given date, this can be set to the offset to adjust the calculated date.
For example, to calculate the day after Thanksgiving, the value of this parameter would be set to 1 (one day after Thanksgiving, which is the 4th Thursday in November). You cannot use the 4th Friday to calculate the date because if the month starts on a Friday, the calculated date would be a week too early. As such, the nOffset parameter is used instead.
// Returns 11/28/2002 (Thanksgiving)
dtThanksgiving = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Thursday, 0);
// Returns 11/29/2002 (Day after Thanksgiving)
dtDayAfterTG = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Thursday, 1);
// Returns 11/22/2002 (Fourth Friday isn't after the fourth
// Thursday in 2002 hence the use of the nOffset parameter
// in the call above).
dtFourthFri = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Friday, 0);
' Returns 11/28/2002 (Thanksgiving)
dtThanksgiving = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Thursday, 0)
' Returns 11/29/2002 (Day after Thanksgiving)
dtDayAfterTG = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Thursday, 1)
' Returns 11/22/2002 (Fourth Friday isn't after the fourth
' Thursday in 2002 hence the use of the nOffset parameter
' in the call above).
dtFourthFri = DateUtils.CalculateFloatingDate(2002, 11,
DayOccurrence.Fourth, DayOfWeek.Friday, 0)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ArgumentException | This is thrown if None is passed for the DayOccurrence parameter. |