DateTimeExtensionsOrdinalDate(OrdinalWeekday, DayOfWeek, Int32, Int32) Method

Returns the date of the nth occurrence of a particular weekday in a given month.

Definition

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.2.9017.0
C#
public static DateTime OrdinalDate(
	OrdinalWeekday occurrence,
	DayOfWeek dayOfWeek,
	int year,
	int month
)

Parameters

occurrence  OrdinalWeekday
The number of the occurrence.
dayOfWeek  DayOfWeek
The day of week to use.
year  Int32
The calendar year to use.
month  Int32
The month to use, where 1 = January and 12 = December.

Return Value

DateTime
A DateTime structure representing the date sought.

Remarks

The following table shows the output of the OrdinalDate method:
occurrencedayOfWeekyearmonthResult
FirstMonday201442014-04-03
FirstTuesday2014112014-11-04
ExactTuesday200411ArgumentOutOfRangeException

Example

C#
var thanksgiving = DateTimeExtensions.OrdinalDate(OrdinalWeekday.Fourth, DayOfWeek.Thursday, 2014, 11);

// Result: 2014-11-27

See Also