IPrjTask.ConstraintDate

Syntax

ConstraintDate: DateTime;

Description

The ConstraintDate property determines a date constraint for task execution.

Comments

The property is relevant on using a specific type of task constraint by time.

Example

To execute the example, add a link to the ProjectPlanning system assembly.

Sub UserProc;
Var
    
Project: IPrjProject;
    Tasks: IPrjTaskCollection;
    Task: IPrjTask;
    Depend: IPrjTaskDependency;
    FPeriod: IPrjTaskPeriod;
    i: Integer;
Begin
    Project := 
New PrjProject.Create;
    
// Set project start date
    Project.StartDate := DateTime.Parse("20.02.2020");
    Project.UseStartDate := 
True;
    
// Get collection of project tasks
    Tasks := Project.Tasks;
    
// Add the first task
    Task := Tasks.Add;
    Task.Key := 
1;
    Task.Name := 
"№1";
    Task.PlanPeriod.Duration := 
7;
    Task.ConstraintType := PrjTaskConstraintType.StartNoEarlierThan;
    Task.ConstraintDate := DateTime.Parse(
"25.02.2020");
    
// Add the second task
    Task := Tasks.Add;
    Task.Key := 
2;
    Task.Name := 
"№2";
    Task.PlanPeriod.Duration := 
10;
    Depend := Task.Dependencies.Add;
    Depend.PredecessorTaskKey := 
1;
    Depend.Type := PrjTaskDependencyType.FinishToFinish;
    
// Run calculation
    Project.Plan;
    
For i := 0 To Tasks.Count - 1 Do
        Task := Tasks.Item(i);
        FPeriod := Task.ForecastPeriod;
        Debug.WriteLine(
"Task execution " + Task.Name + " from " + 
        FPeriod.StartDate.ToString + 
" to " + FPeriod.FinishDate.ToString + 
        
" (duration: " + FPeriod.Duration.ToString + " days)");
    
End For;
End Sub UserProc;

After executing the example, the project will be calculated considering the specified conditions:

The console displays the calculation result:

The first task execution from 25.02.2020 00:00:00 to 02.03.2020 00:00:00 (duration: 7 days)

The second task execution from 22.02.2020 00:00:00 to 02.03.2020 00:00:00 (duration: 10 days)

See also:

IPrjTask