Difference in Duration between Aspose.Tasks and MS Project

It appears there may be a rounding difference between Aspose and MS Project.

I have a simple project with only a couple tasks created in MS Project.

  • The project is using a standard calendar M-F, with 8 hour workdays (1 hr lunch break).

These are the steps:

  • Using Aspose, I create a project
  • Add a task with 9 hour duration.
  • Convert the task to days.
  • Export the project to xml
  • Export the project to mpp format.

Duration from exported XML

  • PT9H0M0S.

Duration from exported mpp (Viewed in MS Project)

  • Duration = 9 hrs
  • Start = 6/6/22 8:00AM
  • Finish = 6/7/22 9:00AM

If create the same task with Duration = 1.13 directly in MS Project, the calculated end date is different.

  • Duration = 1.13 days
  • Start = 6/6/22 8:00AM
  • Finish = 6/7/22 9:02AM

Any recommendation for working around this?

            Project project = new Project();
        project.Set(Prj.StartDate, new DateTime(2022,6,6,8,0,0));
        project.CalculationMode = Aspose.Tasks.CalculationMode.Manual;

        Aspose.Tasks.Task childTask1 = project.RootTask.Children.Add("Pilot Survey");
        childTask1.Set(Tsk.IsManual, false);
        childTask1.Set(Tsk.Start, new DateTime(2022, 6, 6, 8, 0, 0));
        childTask1.Set(Tsk.Duration, project.GetDuration(9, TimeUnitType.Hour));

        project.Save("Rounding_Before.mpp", SaveFileFormat.Mpp);
        project.Save("Rounding_Before.xml", SaveFileFormat.Xml);

        Console.WriteLine("Uid: {0} Dur: {1} TS: {2} Start: {3} Finish: {4}", childTask1.Get(Tsk.Uid), childTask1.Get(Tsk.Duration), childTask1.Get(Tsk.Duration).TimeSpan, childTask1.Get(Tsk.Start), childTask1.Get(Tsk.Finish));
        Console.WriteLine("");

        childTask1.Set(Tsk.Duration, childTask1.Get(Tsk.Duration).Convert(TimeUnitType.Day));

        Console.WriteLine("Uid: {0} Dur: {1} TS: {2} Start: {3} Finish: {4}", childTask1.Get(Tsk.Uid), childTask1.Get(Tsk.Duration), childTask1.Get(Tsk.Duration).TimeSpan, childTask1.Get(Tsk.Start), childTask1.Get(Tsk.Finish));

        project.Save("Rounding_After.mpp", SaveFileFormat.Mpp);
        project.Save("Rounding_After.xml", SaveFileFormat.Xml);

image.png (13.6 KB)

Rounding.zip (53.5 KB)

image.png (12.7 KB)

@leglandpalisade
I have created an issue with ID TASKSNET-10559 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@leglandpalisade,

I don’t see a error.

9h is 1.125 days (MS Project doesn’t allow three decimal places, so you cannot set it by typing “1.125d” in Duration field, but can set it by typing “9h”).

1.13 days is 1.13 * 8 * 60 = 542,4 minutes = 9 h + 2 minutes.

In your example the duration is set to 9h programmatically.
If you set the Duration to 1.13 days
using the following line

childTask1.Set(Tsk.Duration, project.GetDuration(1.13D, TimeUnitType.Day));

you’ll get the same Finish date as shown in MS Project when you type “1.13h” in Duration field

Finish = 6/7/22 9:02AM (in fact 9:02:24AM, but MS Project does not show seconds).