duration & date calculation

D

doniy

Hello,

I'm writing a mini-program in MSP2000.
Now I have a problem:
I want to calculate a finish date using a start date & a duration.
I got the duration by using dur=task(i).duration
for example the duration for task(i) is 12 days,
then I got the dur=task(i).duration ( = 5760 )
then I can calculate the finish date: finishdate=DateAdd(startdate,dur,cal1)
I must consider the task calendar while calculating.
the problem is the task calendar can be ignored by using a duration as 4edays
So my question is how can I identify the duration (the number of 5760 is
12days or 4edays), otherwise I will get 2 different finishdate
I have this problem also for lag ( lag can be day, eday or %, but what i can
get using vba is all in minutes, how to interpret)

thanks in advance
 
J

John

doniy said:
Hello,

I'm writing a mini-program in MSP2000.
Now I have a problem:
I want to calculate a finish date using a start date & a duration.
I got the duration by using dur=task(i).duration
for example the duration for task(i) is 12 days,
then I got the dur=task(i).duration ( = 5760 )
then I can calculate the finish date: finishdate=DateAdd(startdate,dur,cal1)
I must consider the task calendar while calculating.
the problem is the task calendar can be ignored by using a duration as 4edays
So my question is how can I identify the duration (the number of 5760 is
12days or 4edays), otherwise I will get 2 different finishdate
I have this problem also for lag ( lag can be day, eday or %, but what i can
get using vba is all in minutes, how to interpret)

thanks in advance

doniy,
Just a dumb question to start things off. Since Project automatically
calculates Start and Finish dates, and it "knows" the form of an entry
in the Duration field or Predecessor/Successor fields, why do you need
to replicate what is already done?

Without spending a whole lot of time trying to find a more elegant
solution, here is one approach that will work. If the entries in the
Duration field or in the Predecessor/Successor fields may have a mixture
of working time, elapsed time, or percent, then some "If" statements
with string manipulation can ferret out their true colors (so to speak).
String manipulation cannot be used directly on the Duration field but it
can be used directly on the Predecessor/Successor fields. For the
Duration field, if the contents of the field are copied (actual copy,
not by object transfer) to a spare text field, then string manipulation
can be used. For example, let's say a task has a duration of 5 edays. If
that value is copied to spare Text1, you can use the following:
Sub test()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If InStr(1, t.Text1, "e") Then
t.Finish1 = DateAdd("d", t.Duration / 1440, t.Start)
Else
t.Finish1 = Application.DateAdd(t.Start, t.Duration)
End If
End If
Next t
End Sub

Note that in the second date add form, no conversion of the duration
value is necessary because the default project calendar automatically
accounts for working time and that the default entry is in "days".

A similar process can be used for the string in the Predecessor field,
although if there are multiple predecessors, the whole string will need
to be parsed.

Hope this helps.
John
Project MVP
 
D

doniy

Thanks John,
To calculate finish date is only one thing (I use my own start date, not the
start date from MSP)
I 'm writing a custom form to list pred/succ for the selected task with more
detail information than MSP, including (Total slack, free slack, duration,
relationship, lag)
I have problem in interpreting duration & lag so that it can be correctly
show in the form.
another issue is I 'm trying to find out the driving pred/succ, and mark it
in the form.
The method I use is to calculate the start date using all its preds than
compare with the date calculated by MSP, if it is the same, then the pred is
considered driving. So I need to interpret Lag correctly.(is there any other
method to indentify driving pred?)
 
J

John

doniy said:
Thanks John,
To calculate finish date is only one thing (I use my own start date, not the
start date from MSP)
I 'm writing a custom form to list pred/succ for the selected task with more
detail information than MSP, including (Total slack, free slack, duration,
relationship, lag)
I have problem in interpreting duration & lag so that it can be correctly
show in the form.
another issue is I 'm trying to find out the driving pred/succ, and mark it
in the form.
The method I use is to calculate the start date using all its preds than
compare with the date calculated by MSP, if it is the same, then the pred is
considered driving. So I need to interpret Lag correctly.(is there any other
method to indentify driving pred?)

doniy,
I'm sorry if I don't appreciate what you are trying to do but it seems
like you're going through a whole lot of effort for information that is
already available in Project. For example, I still don't understand why
you want to independently calculate finish date, and where exactly does
your start date come from?

It's been a while since I worked with critical paths, but as I recall
the driving predecessor(s) will be the one with the smallest Total
Slack. Also, were you aware that you can display the information you
mention (i.e. Total Slack, Free Slack, Duration, etc.) in a user defined
template box on the Descriptive Network Diagram?

You might want to take a look as some of the macros developed by fellow
MVP, Jack Dahlgren. You can access Jack's webpage at:
http://masamiki.com/project/macros.htm
In particular, take a look at his "Trace" and "Follow Earliest
Predecessor" macros.

John
Project MVP
 
J

JackD

You definitely have to take into account lag in your calculation. You can
read the value and add/subtract as required. You probably also want to check
to see what the task constraints are and in some cases it may be the
successor which is "driving" the task.
Proj 2007 supposedly ID's the driving tasks, so if you can wait for a while
it may make all this unnecessary.

-Jack Dahlgren
 
D

doniy

Thanks JackD.
I think you understand what I mean. pred. with smallest total slack maybe
not the driving pred.

Good news that MSP 2007 will have this function.

Thanks for your sharing your codes, I have alreay read them, it realy helps me

Best regards,
 
J

JackD

You are right, total slack may not indicate the driving predecessor in some
cases.
Good luck with what you are doing.

-Jack Dahlgren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top