DateSerial question

J

Joy

I use
tsk.Start = DateSerial(yy, mm, dd) to set a task's Start
yy is 2009, mm is 9, dd is 18, I debug that DateSerial(yy, mm, dd) is
what I want: 09/18/2008
but tsk.start changes to 09/17/2008

do I use the wrong way to copy dates?
how to ensure that tsk.Start is always the same as DateSerial(yy, mm, dd)
thanks
 
J

Jan De Messemaeker

Hi,

Yes, you use an inefficient way to set dates.
The general rule is you do not set dates, Project calculates them.
So all you can do is influence those dates by links and constraints.
Thus the instruction task.start=somedate generates a constraint (in this
case, start no earlier than) which will be one of the rules influencing the
task's start and finish dates. Links are stronger than a SNET constraint so
the resulting start date may be different from what you enter (manually or
through VBA, does not matter).

Maybe you'll tell me that foir this very special task, the date MUST
absolutely so and so, becuse Big Brother has decided so (you wouldn't set
the date for all tasks, than don't use a schedulin tool!). In that case use
the following instructions
task.constrainttype=pjMSO
task.constraintdate=somedate

As a general comment, I wish you the best of courage... to steer Project
through VBA before learning the scheduling engine...

Greetings,


--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
J

Joy

in our old macros, we don't consider that some user may use regional
language.
we import a date string in format 'mm/dd/yyyy' (like 12/23/2009) to Start
and Finish field of a task. it always works OK.

later, we found that if user uses date format like 'dd/mm/yyyy' (set their
own regional), the import causes some problem. so what we do is to import the
date string into a Text field, parse it into dd, mm and yy, and use
dateSerial to create a Date. then copy the Date to Start or Finish. when we
copy it, we find that some of them match, and some of them do not.

Do you have any better suggestions?

thanks,
 
J

Jack Dahlgren MVP

If it must match and you do not want to set a constraint, you can set actual
start.
Once you do this though, the task date won't change in response to any
changes to predecessors.

-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

Similar Threads

Date fnction throws error one one file 1
Capturing a task id 0
Date Format 10
strange chars created.. 0
Timetable 7
Display billing month based on start date and end date 5
date confusion 2
Dates in a macro 4

Top