How to Convert Existing Microsoft Project Task Durations from Days to Hours
Question details
The user needs to convert existing task durations from days to hours because modifying the project schedule settings does not automatically update the format of previously entered tasks.

- Product
- Microsoft Project
- Device & OS
- not provided
- Scenario
- Updating the default duration display format in a dynamically calculated project file and attempting to apply this format change to all pre-existing tasks.
- Observed behavior
- Changing the Project duration display to hours does not update existing tasks. Additionally, some summary rows display arbitrary or unexpected hour values due to calculation conflicts.
Before running any macros or modifying task durations in bulk, save a copy of your project file as a backup. Ensure your project calendar is correctly configured (File > Options > Schedule) so that your 'Hours per day' setting accurately reflects your expected conversion.
Use a VBA Macro to Convert Task Durations Automatically
Running a custom VBA macro is the most efficient way to scan all existing tasks and automatically rewrite their duration values from days to hours.
Since changing the display format in Microsoft Project only affects newly created tasks, existing tasks remain in their original unit (days). The macro below identifies all non-summary tasks currently displayed in days and converts them to hours.
Press ALT + F11 in Microsoft Project to open the Visual Basic for Applications (VBA) editor.
Click 'Insert' from the top menu and select 'Module' to create a blank script window.
Copy and paste the following code into the module window: Sub ConvertDur() Dim t As Task For Each t In ActiveProject.Tasks If Not t Is Nothing Then If InStr(1, t.GetField(FieldID:=pjTaskDuration), "d") > 0 And t.Summary = False Then SetTaskFieldByID FieldID:=pjTaskDuration, Value:=CStr(t.Duration / 60) & " h", TaskID:=t.ID End If End If Next t End Sub
Close the VBA editor, press ALT + F8 to open the Macros dialog, select 'ConvertDur' from the list, and click 'Run'.

Manually Reset Tasks and Clear Conflicting Resources
If you prefer not to use VBA, you can manually trigger a recalculation of task durations and clear arbitrary hour values caused by improper resource assignments.
Manage Project Timelines Easily with WPS Office
Complex project management software can sometimes overcomplicate simple task tracking with rigid calculation rules and VBA requirements. If you need a straightforward, highly compatible way to track project timelines and resources, WPS Office provides powerful Spreadsheet tools. Build custom Gantt charts, track task durations effortlessly, and enjoy full compatibility with Microsoft Office formats.
- 1. Download and Install: Get WPS Office for free from the official website and install it on your PC, Mac, or mobile device.
- 2. Open WPS Spreadsheet: Launch the WPS Office application and open a new Spreadsheet document.
- 3. Use a Project Management Template: Click on the 'Templates' tab, search for 'Project Management' or 'Gantt Chart', and download a free template to start tracking task durations in any unit you prefer.

Frequently Asked Questions
Why didn't my existing task durations update when I changed the project schedule settings to hours?
In Microsoft Project, changing the default duration unit via File > Options > Schedule only dictates how newly created tasks are formatted. Existing tasks retain the format they were originally entered in, requiring a manual update or a VBA macro to convert them.
Why are there arbitrary hour values appearing in my summary task rows?
Summary task durations are automatically calculated based on the start and finish dates of their subtasks. If you have cost, work, or material resources improperly assigned directly to a summary task, it can confuse the calculation engine and result in unexpected duration values.
How do I ensure a 'day' equals exactly 8 hours when converting?
Before converting, go to File > Options > Schedule, and verify that the 'Hours per day' setting is exactly 8 (or your preferred working hours). When task durations are mathematically converted by a script or the system, it relies on this specific setting to determine the correct hourly output.




