method Chart.AddNonworkingDate (Date as Variant)
Adds a nonworking date.

TypeDescription
Date as Variant A Date expression that indicates the date being marked as nonworking day or a string expression that specifies the repetitive expression that defines the non-working days as Easter, Christmas or Holydays. For instance the "month(value)=7 or ( month(value) = 12 and day(value)=25 )" indicates July and December 25th is a non-working dates. The string version of the AddNonworkingDate supports value formatting. The value keyword indicates the date being queried. If the expression is not syntactically correct the non-working date expression is not added and so represented.
Use the AddNonworkingDate method to add custom dates as nonworking days. Use the NonworkingDays property to mark days in a week as being as nonworking. Use the ShowNonworkingDates property to show or hide the nonworking dates in the control's chart area. Use the RemoveNonworkingDate method to remove a specified date from the nonworking dates collection. The RemoveNonworkingDate method removes only a date previously added using the AddNonworkingDate method. Use the ClearNonworkingDates method to remove all nonworking dates. Use the NonworkingDaysPattern property to specify the pattern being used to fill non-working days. The NonworkingDaysColor property specifies the color being used to fill the non-working days. Use the DateChange event to notify whether the user browses a new date in the chart area. Use the IsNonworkingDate property to retrieve a value that indicates whether a date is marked as nonworking day. Use the Add("A:B") to add a bar that displays the bar A in the working area, and B in non-working areas. Use the ItemNonworkingUnits property to specify different non-working zones for different items.

The control supports the following ways of specify the non-working parts for items:

The following screen shot shows the chart with no custom non-working dates ( just defined by the NonworkingDays property as exSaturday and exSunday )

The following screen shot shows the chart with 3 custom non-working dates ( #12/22/2009#, #12/23/2009#, #12/24/2009# )

The following screen shot shows the chart with a repetitive formula defining the January the 1st and 6th as "month(value) = 1 and ( day(value) in (1,6) )"

2009

2008

The following screen shot shows the chart with a repetitive formula defining the year 2009 as being non-working and the April of 2010 using "year(value) = 2009 or (month(value) = 4 and year(value) = 2010)"

Here's few samples for repetitive expression:

The expression supports predefined functions listed here. The value keyword in the expression indicates the date value being queried. 

The following samples handles the DateChange event to add a new hard-coded date. The DateChange event notifies the application once the chart displays or changes its first visible date. This version could be time consuming, but it can be improved. For instance, you can add a member or a has table that changes / adds a new working date when the year is changed so actually the action could be added, only when the chart displays a new year.  

The following VB sample marks the 11th of each month as nonworking day ( the code enumerates the visible dates, and marks one by one, if case ):

Private Sub G2antt1_DateChange()
    With G2antt1
        .BeginUpdate
        With .Chart
            Dim d As Date
            d = .FirstVisibleDate
            Do While .IsDateVisible(d)
                If Day(d) = 11 Then
                    If Not (.IsNonworkingDate(d)) Then
                        .AddNonworkingDate d
                    End If
                End If
                d = .NextDate(d, exDay, 1)
            Loop
        End With
        .EndUpdate
    End With
End Sub

The following VB.NET sample marks the 11th of each month as nonworking day:

Private Sub AxG2antt1_DateChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxG2antt1.DateChange
    With AxG2antt1
        .BeginUpdate()
        With .Chart
            Dim d As Date = .FirstVisibleDate
            Do While .IsDateVisible(d)
                If d.Day = 11 Then
                    If Not (.IsNonworkingDate(d)) Then
                        .AddNonworkingDate(d)
                    End If
                End If
                d = .NextDate(d, EXG2ANTTLib.UnitEnum.exDay, 1)
            Loop
        End With
        .EndUpdate()
    End With
End Sub

The following C# sample marks the 11th of each month as nonworking day:

private void axG2antt1_DateChange(object sender, EventArgs e)
{
	axG2antt1.BeginUpdate();
	EXG2ANTTLib.Chart chart = axG2antt1.Chart;
	DateTime d = Convert.ToDateTime(chart.FirstVisibleDate);
	while ( chart.get_IsDateVisible(d) )
	{
		if ( d.Day == 11 )
			if ( !chart.get_IsNonworkingDate( d ) )
				chart.AddNonworkingDate(d);
		d = chart.get_NextDate(d, EXG2ANTTLib.UnitEnum.exDay, 1);
	}
	axG2antt1.EndUpdate();
}
}

The following VFP sample marks the 11th of each month as nonworking day ( DateChange event ):

*** ActiveX Control Event ***

With thisform.G2antt1
    .BeginUpdate
    With .Chart
        local d
        d = .FirstVisibleDate
        Do While .IsDateVisible(d)
            If Day(d) = 11 Then
                If Not (.IsNonworkingDate(d)) Then
                    .AddNonworkingDate(d)
                EndIf
            EndIf
            d = .NextDate(d, 4096, 1)
        enddo
    EndWith
    .EndUpdate
EndWith