Forum Discussion

Craigsquestions's avatar
Craigsquestions
Copper Contributor
Aug 17, 2022

Datediff

Good day, 

 

I'm using project desktop. I used the the date diff formula to calculate the days left from now until the finish date of a task, but I want to know is there a way to use this formula or any other method to calculate/show the amount of days between 2 specific tasks. They are not direct predecessors.

 

Thanks in advance

  • Craig --

    No, there is no way to write a formula in Microsoft Project that will calculate the amount of days between two tasks. Sorry, but hope this helps.
  • John-project's avatar
    John-project
    Silver Contributor
    Craigsquestions,
    Yes, but you can't do it with a custom field formula since that formula can only reference data on a single task line.

    However, with VBA, virtually anything can be done. If you can supply more details (e.g. how the 2 specific tasks are determined, are you looking for working days or calendar days, etc.), I can write some code for you.

    John
  • ismet_kocaman's avatar
    ismet_kocaman
    Brass Contributor

    Craigsquestions 

    I can offer the following "impractical" approach. Suppose that you need to constantly watch the days between T1's finish and T3's start.

     

    Flag1 renamed as Mark_Finish, Flag2 renamed as Mark_Start

     

    Finish1's formula: iif( [Flag1], [Finish], ProjDateValue("NA"))
    Select "Rollup: Maximum" for summary rows

     

    Start1's formula: iif( [Flag2], [Start], ProjDateValue("NA"))
    Select "Rollup: Maximum" for summary rows


    Number1's formula: iif( [ID] = 0, ProjDateDiff( [Finish1], [Start1] ) / [Minutes Per Day], 0)
    Select "Use Formula" for summary rows

     

    And this is the result:

     

    You can hide the columns for Finish1 and Start1, after having done with testing.   

     

Share