# Task Duration

## Content



The duration of the task specifies how long the task will take to complete. To set task duration in GanttView, you can use <span data-popup-content="This property is available in \u003ca href=\u0022/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.GanttView.Task.Duration.html\u0022\u003e.NET\u003c/a\u003e and \u003ca href=\u0022/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.GanttView.Task.Duration.html\u0022\u003e.NET Framework\u003c/a\u003e." data-popup-title="Duration" data-popup-theme="ui-tooltip-green qtip-green">Duration</span> property of the <span data-popup-content="This class is available in \u003ca href=\u0022/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.GanttView.Task.html\u0022\u003e.NET\u003c/a\u003e and \u003ca href=\u0022/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.GanttView.Task.html\u0022\u003e.NET Framework\u003c/a\u003e." data-popup-title="Task" data-popup-theme="ui-tooltip-green qtip-green">Task</span> class. Additionally, you can use the [DurationUnits](/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.GanttView.Task.DurationUnits.html) property which takes values from [DurationUnits enumeration](/componentone/api/wpf/online-ganttview/dotnet-api/C1.WPF.GanttView/C1.WPF.GanttView.DurationUnits.html) to set the duration unit to Minutes, Hours, Days, Weeks, or Months.

The following image showcases a GanttView task whose duration is set to 5 days.

![task notes](https://cdn.mescius.io/document-site-files/images/14a478dc-2b0f-437a-969b-b17e430e375e/images/notes_task.png)

To set the task duration in the GanttView to 5 days, use the following code. This example uses the sample created in [Quick Start](/componentone/docs/wpf/online-ganttview/GanttView-QuickStart).

```csharp
//Set duration unit and duration of a task
t.DurationUnits= DurationUnits.Days;
t.Duration = 5;
```

Besides, task duration can be set at runtime through the [Task Information dialog](/componentone/docs/wpf/online-ganttview/dialogboxes/Task-Information-Dialog), which can be accessed by clicking the **Task Information** button from the [Toolbar](/componentone/docs/wpf/online-ganttview/GanttView-Toolbar).