We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Duration Values not Calculated Correctly


I’m having issues with duration values in my generated Microsoft Project file.

First Issue: If you run the attached sample and view the output you’ll notice that the duration value for the “CHILD 1” task is showing as 1 day which is based on the assigned resource and number of units. However, when I preform a calculate project it changes to 2.55 which, correct me if I’m wrong, is because all tasks have been assigned the same resource. Should this be calculated correctly during the project recalculate function call and display 2.55 on initial open of the project file? Keep in mind that I have the calculation mode property set to none to increase performance.

Second Issue: If you delete the output file, comment out line 62, reinstate line number 63, run the attached sample and view the output file you’ll notice that the duration value for “CHILD 1” has been set to 0. Basically, by adding in line number 63 we are trying to indicate that this particular task is complete. I’ve tried setting the actual start, finish and duration values with no such luck, the duration value remains at 0 days. If I were to attempt a save via Microsoft Project at this point I would get an error indicating I should save it as another format (Seems to be the result of this duration issue). Any ideas as to how I can get the duration value to calculate correctly?

I’m using VS 2010, MSP 2010 and Aspose Task 9.5.0. I’ve attached the sample application and template file. If you need anything further, please let me know.

Thanks, Calvin

Hi Calvin,

Thank you for contacting Aspose support team again.

Regarding the first issue, I am afraid that this issue is not re-produced at our end. CHILD 1 duration remains same after opening it in MSP and performing recalculation.

We are working on the second issue and will share our feedback soon once the analysis is completed.

Hi Kashif,

Thanks for the quick response.

Just noticing now that the first issue is dependent on the time of day that the project is created. I tried to recreate first thing this morning after reading your response and the duration value for all tasks remained at 1 day after preforming a calculate project. I created the project just prior to the working day start as defined in the standard calendar (8:00 AM).

The second issue was the most concerning as it is causing (or seems to be causing) the save issue.

Thanks, Calvin

Hi Calvin,

We are working on this issue and need some assistance. If we look into output file, it is observed that CHILD1 has same start and finish time which is causing the duration to be set 0. Could you please confirm why the start/finish time is same? If we set it to 8 hours time span, duration is automatically set to 1 day. On the other hand if we open output file in MSP 2010, and try to set duration to 1 day, it reverts to 0 day. Your feedback will help us to assist you accordingly.

Hi Kashif,

When the MSP file is generated with line number 63 commented out and 62 reinstated the CHILD 1 task has it’s finish date and time automatically calculated (See attachment Result_1.mpp).

With the reverse, line 63 reinstated and 62 commented out the finish date is auto calculated to match the start time for some reason (See attachment Result_2.mpp). This is not my intention but is what’s happening. I’ve tried setting the Actual Finish date, as a test, which didn’t seem to help.

I was thinking that the project.Recalculate() call would calculate the finish date and times accordingly (it seems to do so when I’m not marking a task as complete). If not then I would have to set the finish times manually and I’m not sure how I would accomplish that with Aspose Tasks seeing how I would have to factor in non-working days, hours per day, start times, etc.

I hope this helps…if you need anything further on my end, please let me know.

Thanks, Calvin

Hi Calvin,

We can set finish date by calculating number of hours between two dates based on particular calendar using ATask.Calendar.GetWorkingHours(). You may please use following sample code to set the finish date as it takes care of the calendar and share the feedback.

Project proj = new Project(@“Blank2010.mpp”);
Task task1 = proj.RootTask.Children.Add(“Task 1”);
task1.Set(Tsk.IsManual, true);
DateTime startDate = new DateTime(2016, 8, 3, 8, 0, 0);
DateTime finishDate = new DateTime(2016, 8, 31, 17, 0, 0);
task1.Set(Tsk.Start, startDate);
ATasks.Calendar cal = proj.Get(Prj.Calendar);
double totalHours = cal.GetWorkingHours(startDate, finishDate).WorkingHours.TotalHours;
task1.Set(Tsk.Duration, proj.GetDuration(totalHours, TimeUnitType.Hour));
proj.Save(“output2.mpp”, SaveFileFormat.MPP);

Hi Kashif,

I’m not able to use the code you’ve provided. My issue is that I have a potential start date and expected duration of a task in hours of which I want MS Project to calculate the finish date. This seems to work as expected until I try to complete a task, either by setting the remaining hours to zero, or setting the actual duration.

After further investigation I’ve noticed that the duration value, for some reason, gets reset to zero days automatically when I set the actual duration to match the task duration. I need to set the actual duration to match the task duration in order to get the task completed indicator to show. If I leave this line out the duration is calculated correctly however the start and finish date are the same, which is not correct.

How can I mark the task as complete and have the duration calculated correctly at the same time? How can I mark a task as complete and have the task finish date calculate correctly based on the task duration? You should be able to recreate within the original code I sent along. The Actual Start, Actual Finish and Task Finish setting has no affect on the dates when completing a task, any ideas as to why?.Also, you can remove the Asn.Units line of code as well as it’s no longer needed on my end.

Thanks, Calvin

Hi Calvin,

I have tried to re-produce the Issue 2 where duration of task Child 1 is set to 0 after running the code by commenting line 62 and un-commenting line 63. The result.mpp file is opened in MSP 2010 and it is observed that task is marked as completed and duration is also not 0. Could you please test the attached code again which is just converted to form based application for simplicity?

I have attached the images where result.mpp file is opened in MSP 2010 along with the duration column displayed. Sample project and result.mpp file is also attached.

Hi Kashif,

I’ve downloaded and ran your sample solution and the resulting MSP file ends up with a duration of zero for the CHILD 1 task. I’ve reviewed the result file you’ve attached and found a slight difference. The template file that I’m using as a starting point has a calculate project call on initial open of the project file. If you were to open the result file you sent along and select the calculate project button the duration would reset to zero. Is this the result of the start and finish time for the task being calculated as the same value? If the task is not marked as complete the start and finish dates are calculated correctly. Can you tell me what properties need to be set in order to prevent the duration reset to zero and the incorrect finish date? Seems as though MS Project is expecting something that is not being passed.

If you need anything further on my end, please let me know.

Thanks, Calvin

Hi Calvin,

I have tested the issue using the template file provided in the first post on this thread. You may please share the exact template file which should be used for testing.

This sample project contains lot of extra code and functionality which seems to have no effect on the current issue. Could you please help us to strip down the project to the minimum code which can be analyzed here to observe the issue? Following functions are requested to be simplified/removed as much as possible to prepare a simplest project for testing.

  1. InitialMSPData():
    1. Please remove un-necessary columns from this table
    2. Also it seems that only first two rows (tasks) are sufficient to re-produce the issue, so only two rows should be there.
  2. processTask():
    1. This function should be simplified and only required arguments should be passed and used.
  3. setProjectTable():
    1. Only required fields should be added.
You may also consider removing the functionality about the extended attributes if not required. Your assistance and help in this regard will be much appreciated here to provide timely feedback.

Hi Kashif,

I am trying to access your website resources but its saying:

403 Forbidden
nginx/1.4.6 (Ubuntu)

Is there any problem with the site currently. Is it down?


Thank you for contacting Aspose support again. I am afraid that no issue is observed and forums are working fine. Please check your network/internet settings and also test forums on some different machine. We are facing no issue in accessing the forums.