I often have to change the format of the date to check and "adjust" new sequences activities. It is very inconvenient to click always through the menu so I tried to find some VBA-macros for this issue. My goal is to set a shortcut to switch between ("dd.mm." and "dd.mm. hh.mm") as a time format in all projects.

Unfortunately, I didn't find something suitable and the attempts to do it by myself weren't really sussesful so far. How can I toggle dates between two formats in MS Project?

4 Answers 4


NB: Search and shopping questions are off-topic, as are tech support and custom programming questions. General process and basic configuration questions are often on topic, but the question as originally phrased didn't meet those criteria. It has since been edited to be on topic, but if you're looking for a programming solution then it's no longer about the practice or profession of project management.

You've received some reasonable answers already. Since you didn't explain why you need to do this, I'm going to try to address the X in what appears to be an X/Y question.

  1. Determine whether this is really critical path.
  2. If you need to do it, and none of the other answers here suit you, then it's a technical support question for Microsoft.
  3. If it turns into a custom programming question, then this is a feature request for your in-house tool support or custom programming resources.
  4. If you need #2 or #3 then you need to include those resources or costs in your project, and get them onto the project plan if it's going to consume project resources.
  5. If it's not critical path or you don't want to treat it as a support or development issue, then consider an alternative approach to reach your goal that isn't so tool-driven.
  • Hi Todd, as mentioned I need sometimes the exact time to analyze the connections of tasks (it may happened that different calendar are applied). But in general I prefer small columns in the layout - therefore I try to solve this issue by coding a small macro. I am very happy with the possibility of using vba in MS Project. It helps me a lot for other issues... I would be happy if there is an in-house support - so I try to help myself anyhow
    – Daniel
    Commented Dec 4, 2022 at 22:36

Use the DefaultDateFormat method of the application object to change the date format. The available options are listed here.

For example:

Application.DefaultDateFormat = pjDate_mmm_dd_hh_mmAM

Yields: Nov 28 8:00 AM

  • Hello Rachel, thanks for your advice with the DefaultDateFormat. I think this is the way I have to go - even if I still didn't find out how to process this into a working VBA-code (I am able to adapt codes, but still learning to create codes by myself).
    – Daniel
    Commented Dec 4, 2022 at 22:15

I think you can switch without VBA.

  1. Create 2 Tables, one with dd.mm.yy date format & the other with dd.mm.yy hh:mm date format.
  2. Then create 2 Global Views, one for each date format and assign the appropriate Table from #1 above to each View
  3. These 2 Views will be available in your Gantt Chart list for all projects, and you can easily switch.
  • Yes, that's also an idea. Nevertheless I would like to solve it with a code + shortcut. That's more practical during my daily work. I have already several views for different purposes and do not want to double them...
    – Daniel
    Commented Dec 4, 2022 at 22:20

Creating a button to toggle the date formats would be best for you. You will need to write some custom VBA code to do this. Here are the steps

  1. While in MS Project, Open the VBA Code editor (lots of ways to do this, I recommend alt + F11)

  2. In the VBA window, expand the section called ProjectGlobal (Global.MPT) VBA Editor Global

  3. Right click the Modules folder and click the button to add a new Module Adding a module

  4. Use this code in your module:

    Public Sub ToggleDateFormat()
     If Application.DefaultDateFormat = pjDate_mm_dd Then
         Application.DefaultDateFormat = pjDate_mm_dd_yy_hh_mmAM
     End If
     If Application.DefaultDateFormat = pjDate_mm_dd_yy_hh_mmAM Then
         Application.DefaultDateFormat = pjDate_mm_dd
     End If
    End Sub
  5. Add a button to the ribbon or quick access toolbar that points to this macro. Do this by clicking File --> Options --> Customize Ribbon OR Quick Access Toolbar --> Choose Commands From Macros --> Find the Macro --> Click Add.

enter image description here

Now you will have a button you can click to toggle the date format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.