DateUtilsCalculateFixedDate Method

This method is used to calculate the date on which a fixed day occurs (for example, July 4th). However, it adjusts the date to the preceding Friday if the date falls on a Saturday or the following Monday if the date falls on a Sunday.

Definition

Namespace: EWSoftware.PDI
Assembly: EWSoftware.PDI (in EWSoftware.PDI.dll) Version: 2023.1.2.0
public static DateTime CalculateFixedDate(
	int year,
	int month,
	int day
)

Parameters

year  Int32
The year in which the day occurs
month  Int32
The month in which the day occurs
day  Int32
The day of the month on which the day occurs

Return Value

DateTime
Returns a DateTime object that represents the date calculated from the settings adjusted if necessary so that it does not occur on a weekend.

Remarks

The FixedHoliday class uses this method to calculate the date on which a holiday is observed rather than the actual date on which it falls when its AdjustFixedDate property is set to true (i.e. to calculate holiday dates for a business).

Example

C#
// Returns 07/04/2003 (7/4 falls on a Friday).
dtDate = DateUtils.CalculateFixedDate(2003, 7, 4);

// Returns 07/05/2004 (7/4 falls on a Sunday so it adjusts it forward
// to the Monday).
dtDate = DateUtils.CalculateFixedDate(2004, 7, 4);

See Also