how to get 'days' from MS Project task field duration?

J

Johnathan

Hi,

I've been figuring out on how to extract the term 'days' from the duration
field in MS Project using vb.net but I couldn't get the solution. When I do
this txtDuration = pj.Duration I only get the numeric value. Could you please
help me? Thanks..
 
J

Jonathan Sofer

Duration in MS Project is stored in minutes. By default, the minutes per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the project
calendar, the duration can vary.

Jonathan Sofer
 
J

Johnathan

actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

Jonathan Sofer said:
Duration in MS Project is stored in minutes. By default, the minutes per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the project
calendar, the duration can vary.

Jonathan Sofer

Johnathan said:
Hi,

I've been figuring out on how to extract the term 'days' from the duration
field in MS Project using vb.net but I couldn't get the solution. When I
do
this txtDuration = pj.Duration I only get the numeric value. Could you
please
help me? Thanks..
 
J

Jonathan Sofer

Sorry, but I do not know how to find this in VBA.

Jonathan


Johnathan said:
actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

Jonathan Sofer said:
Duration in MS Project is stored in minutes. By default, the minutes per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the
project
calendar, the duration can vary.

Jonathan Sofer

Johnathan said:
Hi,

I've been figuring out on how to extract the term 'days' from the
duration
field in MS Project using vb.net but I couldn't get the solution. When
I
do
this txtDuration = pj.Duration I only get the numeric value. Could you
please
help me? Thanks..
 
J

John

Johnathan said:
actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

Jonathan Sofer said:
Duration in MS Project is stored in minutes. By default, the minutes per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the
project
calendar, the duration can vary.

Jonathan Sofer

Johnathan said:
Hi,

I've been figuring out on how to extract the term 'days' from the
duration
field in MS Project using vb.net but I couldn't get the solution. When I
do
this txtDuration = pj.Duration I only get the numeric value. Could you
please
help me? Thanks..

Johnathan,
The unit label in the Duration field is set under Tools/Options/Schedule
tab. Unfortunately like a few other things in Project, you can set the
unit label using VBA but you cannot read it directly.

I can see where you might want to get the value in the Duration field,
but why exactly do you want to get the unit designator? There may or may
not be an indirect way of detecting it.

John
Project MVP
 
J

Johnathan

what article??

John said:
Johnathan said:
actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

Jonathan Sofer said:
Duration in MS Project is stored in minutes. By default, the minutes per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the
project
calendar, the duration can vary.

Jonathan Sofer

Hi,

I've been figuring out on how to extract the term 'days' from the
duration
field in MS Project using vb.net but I couldn't get the solution. When I
do
this txtDuration = pj.Duration I only get the numeric value. Could you
please
help me? Thanks..

Johnathan,
The unit label in the Duration field is set under Tools/Options/Schedule
tab. Unfortunately like a few other things in Project, you can set the
unit label using VBA but you cannot read it directly.

I can see where you might want to get the value in the Duration field,
but why exactly do you want to get the unit designator? There may or may
not be an indirect way of detecting it.

John
Project MVP
 
J

John

Johnathan said:
what article??

Johnathon,
Article? What article? I didn't make any reference to any article.
Perhaps you are seeing the article designation given by some newsreaders
to the posts and responses in this newsgroup. If that's the case, the
"article" is my response. There is no other "article".

John
Project MPV
John said:
Johnathan said:
actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

:

Duration in MS Project is stored in minutes. By default, the minutes
per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration
by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the
project
calendar, the duration can vary.

Jonathan Sofer

Hi,

I've been figuring out on how to extract the term 'days' from the
duration
field in MS Project using vb.net but I couldn't get the solution.
When I
do
this txtDuration = pj.Duration I only get the numeric value. Could
you
please
help me? Thanks..

Johnathan,
The unit label in the Duration field is set under Tools/Options/Schedule
tab. Unfortunately like a few other things in Project, you can set the
unit label using VBA but you cannot read it directly.

I can see where you might want to get the value in the Duration field,
but why exactly do you want to get the unit designator? There may or may
not be an indirect way of detecting it.

John
Project MVP
 
J

Johnathan

oops sorry, I didn't scroll down and read for your previous reply.

John said:
Johnathan said:
what article??

Johnathon,
Article? What article? I didn't make any reference to any article.
Perhaps you are seeing the article designation given by some newsreaders
to the posts and responses in this newsgroup. If that's the case, the
"article" is my response. There is no other "article".

John
Project MPV
John said:
actually I want to get the symbol/unit of the duration not the value. For
examples, days, weeks, months and etc.

:

Duration in MS Project is stored in minutes. By default, the minutes
per
day is 480 (8 hrs * 60 minutes) so you can just divide the pj.Duration
by
480 to get the duration in days.

If you want to make your code more robust, i.e. be able to handle the
duration if you change the default working days to 7.5 for example (450
minutes), you would want to use the variable [Minutes Per Day] which is
defined by the calendar.

FYI, resource calendars overwrite project calendars so once you start
assigning resources to a task that has a different calendar than the
project
calendar, the duration can vary.

Jonathan Sofer

Hi,

I've been figuring out on how to extract the term 'days' from the
duration
field in MS Project using vb.net but I couldn't get the solution.
When I
do
this txtDuration = pj.Duration I only get the numeric value. Could
you
please
help me? Thanks..




Johnathan,
The unit label in the Duration field is set under Tools/Options/Schedule
tab. Unfortunately like a few other things in Project, you can set the
unit label using VBA but you cannot read it directly.

I can see where you might want to get the value in the Duration field,
but why exactly do you want to get the unit designator? There may or may
not be an indirect way of detecting it.

John
Project MVP
 

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