Date UtilsCalculate Occurrence Date Method
Definition
Assembly: EWSoftware.PDI (in EWSoftware.PDI.dll) Version: 2025.1.9.0
public static DateTime CalculateOccurrenceDate(
int year,
int month,
DayOccurrence occur,
DaysOfWeek days,
int offset
)Public Shared Function CalculateOccurrenceDate (
year As Integer,
month As Integer,
occur As DayOccurrence,
days As DaysOfWeek,
offset As Integer
) As DateTimepublic:
static DateTime CalculateOccurrenceDate(
int year,
int month,
DayOccurrence occur,
DaysOfWeek days,
int offset
)static member CalculateOccurrenceDate :
year : int *
month : int *
occur : DayOccurrence *
days : DaysOfWeek *
offset : int -> DateTime Parameters
- year Int32
- The year in which the day occurs
- month Int32
- The month in which the day occurs
- occur DayOccurrence
- The occurrence of the day of the week on which the day falls
- days DaysOfWeek
- The day(s) of the week on which the day can occurs
- offset Int32
- The number of days before or after the calculated date on which the day falls
Return Value
DateTimeReturns a DateTime object that represents the date calculated from the settings.
Remarks
This method is intended for use in finding an occurrence of any one of a set of days of the week and is normally used with the Weekdays or Weekends day of week value. However, the days of week parameter can be any valid combination of days including an individual day of the week.
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. Note that if used, the date returned may not be on one of the days of the week specified to calculate the original unadjusted date.
Example
// Returns 01/06/2004 (fourth weekday in Jan 2004)
dtFourthWeekday = DateUtils.CalculateOccurrenceDate(2004, 1,
DayOccurrence.Fourth, DaysOfWeek.Weekdays, 0);
// Returns 01/08/2004 (fourth weekday plus 2 days)
dtPlusTwo = DateUtils.CalculateOccurrenceDate(2004, 1,
DayOccurrence.Fourth, DaysOfWeek.Weekdays, 2);' Returns 01/06/2004 (fourth weekday in Jan 2004)
dtFourthWeekday = DateUtils.CalculateOccurrenceDate(2004, 1,
DayOccurrence.Fourth, DaysOfWeek.Weekdays, 0)
' Returns 01/08/2004 (fourth weekday plus 2 days)
dtPlusTwo = DateUtils.CalculateOccurrenceDate(2004, 1,
DayOccurrence.Fourth, DaysOfWeek.Weekdays, 2)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.Exceptions
| ArgumentException | This is thrown if None is passed for the DayOccurrence parameter. |