Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating Workdays Between Dates

232 views
Skip to first unread message

Dean Reed

unread,
Dec 10, 2002, 2:20:14 AM12/10/02
to
What is the simplest way to calculate the number of
workdays according to the project calendar between two
dates using VBA? Both the Calendar.Period property and the
DateDiff function calculate calendar days rather than
workdays.

Jack D.

unread,
Dec 10, 2002, 11:03:59 AM12/10/02
to
Try projdatediff.
It takes two dates and the project calendar as parameters and returns the
difference in working days according to the calendar you designate.

--
Please try to keep replies in this group. I do check e-mail, but only
infrequently.
For Macros and other things check http://masamiki.com/project

-Jack Dahlgren, Project MVP


+++++++++++++++++++
"Dean Reed" <de...@dprinc.com> wrote in message
news:048f01c2a01c$959d2ef0$d7f82ecf@TK2MSFTNGXA14...

Dean Reed

unread,
Dec 10, 2002, 12:10:51 PM12/10/02
to
Jack
Please give me an example of how to use this in VBA. I
know that there is a function that can be entered into a
custom fields formula, but that's not my preferred method.
I tried using ProjDateDiff in VBA and got a "Undefined
function" error messae. And I don't see it listed either
int he Object Browser or in Help.
Dean
>.
>

Jan De Messemaeker

unread,
Dec 10, 2002, 12:28:09 PM12/10/02
to
IMHO the application.datediff function calculates as per the project
calendar whereas the VBA.Datediff function uses calendar days
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
"Dean Reed" <de...@dprinc.com> schreef in bericht
news:048f01c2a01c$959d2ef0$d7f82ecf@TK2MSFTNGXA14...

Jack D.

unread,
Dec 10, 2002, 3:20:05 PM12/10/02
to
Sorry, my mistake.
When you are using this function in a custom formula it is called
ProjDateDiff.
When you are using it in VBA it is a method called DateDifference.
It is the same thing, just different names (Thanks Microsoft!)

Here is the syntax:
----------------------------------
DateDifference -Returns the duration between two dates in minutes.
Syntax:
expression.DateDifference(StartDate, FinishDate, Calendar)

expression Required. An expression that returns an Application object.
StartDate Required Variant. The date used as the beginning of the duration.
FinishDate Required Variant. The date used as the end of the duration.
Calendar Optional Object. A resource or task base calendar object. The
default value is the calendar of the active project.
----------------------------------
This code should give you the duration of the first task in your project.
Application.DateDifference(activeproject.Tasks(1).Start,activeproject.Tasks(
1).Finish, Standard)

--
Please try to keep replies in this group. I do check e-mail, but only


infrequently.
For Macros and other things check http://masamiki.com/project

-Jack Dahlgren, Project MVP


+++++++++++++++++++
"Dean Reed" <de...@dprinc.com> wrote in message

news:057d01c2a06f$17400200$89f82ecf@TK2MSFTNGXA01...

Dean Reed

unread,
Dec 10, 2002, 7:00:57 PM12/10/02
to
Jack
Thanks! Works like a charm!
Dean
>.
>

josephine.p.paulraj

unread,
Dec 13, 2002, 4:19:28 PM12/13/02
to
>.
>open a project that has the desired calendar. create a
test task with the given start and end date. use the
duration calculated by project for that test task. do
not dave the project
0 new messages