Free Support Forum - aspose.com

Calculate Duration

Received : 2007/10/03 03:26:09
Message : If I on a task only give StartDate and EndDate I do not get a Duration of the Task.
So I am trying to calculate the duration by subtrtracting the DateTime objects. But if this is set as the Duration, the period will be longer because the duration seems to take into consideration non-working periods (5 days a week instead of 7).
Is there som way to solve this?


This message was posted using Aspose.Live 2 Forum

Dear oseb,

Thank you for considering Aspose.Tasks.

Why do you need to calculate duration?

Actually, there are two types of fields in MS-Project file. One type of fields are required to be set while other fields are called calculated fields. Calculated Fields are calculated each time the file is opened by MS-Project.

If you want to calculate duration to set some Calculate Field, then remember, it will be ignored by MS-Project and MS-Project will recalculate it.

For more information, please see this link.

http://support.microsoft.com/kb/270139

Please feel free to ask any further question.

Hello again

Actually I do not want to calculate it.
From database I have information of start and end of task. I hoped that by setting start and end date the duration will be calculated. But that dues not happen.
Maybe other parameters also needs to be set to achieve that (actual start date etc.).

I see the same problem when setting percent complete. Nothing happened in Project before ActualWork was set.

I am not able to find any information regarding what is calculated values, what must be set to get percent complete etc.
I see in the examples that a startdate and a duration is set on a task. I actually just want to set startdate and enddate, the duration should then be calculated.

I might miss some knowledge about Project in general that makes this difficult for me.

Hello,

MS Project should recalculate all fields when you open this project later.
If you need to get duration in your app, it’s possible to use Calendar.GetDuration method.
It should give you more or less right duration value based on calendar’s exceptions.