Calendar.GetStartDateFromFinishAndDuration

GetStartDateFromFinishAndDuration(DateTime, Duration)

Returns StartDate based on specified FinishDate and Duration.

public DateTime GetStartDateFromFinishAndDuration(DateTime finish, Duration duration)
ParameterTypeDescription
finishDateTimeThe specified finish date.
durationDurationThe specified work duration.

Return Value

Calculated StartDate.

Examples

Shows how to get a start date by finish date and duration.

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get start date by finish date and a duration
var startDate = calendar.GetStartDateFromFinishAndDuration(new DateTime(2020, 4, 10, 9, 0, 0), project.GetDuration(16, TimeUnitType.Hour));

// 8 April 2020 9:00 AM will be printed
Console.WriteLine(startDate);

See Also


GetStartDateFromFinishAndDuration(DateTime, TimeSpan)

Returns StartDate based on specified FinishDate and Duration.

public DateTime GetStartDateFromFinishAndDuration(DateTime finish, TimeSpan duration)
ParameterTypeDescription
finishDateTimeThe specified finish date.
durationTimeSpanThe specified work duration.

Return Value

Calculated StartDate.

Examples

Shows how to get a start date by finish date and duration (as a time span).

var project = new Project(DataDir + "Project1.mpp");

var calendar = project.Calendars.GetByUid(1);

// get start date by finish date and a duration
var startDate = calendar.GetStartDateFromFinishAndDuration(new DateTime(2020, 4, 10, 9, 0, 0), TimeSpan.FromHours(16));

// 8 April 2020 9:00 AM will be printed
Console.WriteLine(startDate);

See Also