Calculating Split Task's Finish Date
Microsoft Project allows users to split tasks when the schedule is interrupted. Aspose.Tasks allows you to calculate the finishing date of a split task.
Split Tasks
The GetTaskFinishDateFromDuration method exposed by the Calendar class is used to calculate a split task’s finishing date from the start date, split parts and duration. The GetTaskFinishDateFromDuration method takes a split task and duration as its arguments and returns the tasks finish date.
Split Tasks in Microsoft Project
To view the start date of a split task in Microsoft Project one can select Gantt Chart from the View menu. The parts of a split task are showing as chunks connected by a line of dots.
Calculating a Split Task’s Finish Date with Aspose.Tasks
The following code examples calculate a split task’s finish date.
1Project project = new Project("New Project.mpp");
2
3// Find a split task
4Task splitTask = project.RootTask.Children.GetByUid(4);
5
6// Find the project calendar
7Calendar calendar = project.Get(Prj.Calendar);
8
9// Calculate task's finish date with different durations
10Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 8 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(8, 0, 0)));
11Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 16 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(16, 0, 0)));
12Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 24 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(24, 0, 0)));
13Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 28 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(28, 0, 0)));
14Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 32 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(32, 0, 0)));
15Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 46 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(46, 0, 0)));
16Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 61 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(61, 0, 0)));
17Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 75 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(75, 0, 0)));
18Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 80 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(80, 0, 0)));
19Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 120 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(120, 0, 0)));
20Console.WriteLine("Start Date: " + splitTask.Get(Tsk.Start).ToShortDateString() + "Duration 150 hours Finish Date: " + calendar.GetTaskFinishDateFromDuration(splitTask, new TimeSpan(150, 0, 0)));