Calculate Task Duration in Different Units

Calculating Durations

It can be useful to calculate the duration of a task in different units such as minutes, hours, etc.

The Tsk class offers provides the Duration property for accessing task duration, which returns the Duration class object. The Convert method exposed as part of Duration class can then be used to calculate task durations in different units. This method takes TimeUnitType as the input argument and returns the duration as a double value.

The following piece of code shows how to use this method to retrieve a task’s duration in different units: minute, day, hour, week and month.