date format from existing project file

R

Ryan Vande

Ok so we extract all our data from excel into a project sheet

We have variables setup as mstask.start which equals ["Start Date"] +
["Start time"]


also same for end date and time but we can sum everything up from the start
I believe.

Now the format of these dates come out as 1/01/01 <-- Example

I want to make a programable decision based off day of week of the listed
jobs within our project sheet. So weekday(date) would be nice, but wont this
return the current day. Or can I use weekday(date) against ["Start Date"] ?

I was trying to cstr("Start Date") To try and get this date as a string and
then I can perform some manipulation on it but I was not getting success. I
was going to Trim the string and set up a array (Sort of speak)

Would there be an easy way to go through each row and based off "Start Date"
distinguish which day the date currently falls on? A i heading the right
direction trying to convert this date into a String?

Can I do something like weekday(date #"Start date"#)

Something to that nature?
 
J

Jack Dahlgren MVP

There are many VBA functions that deal with dates.
I would not convert to a string, just keep the serial date.

You can find the day of the week using the "Weekday" function or
"WeekdayName" function.

Converting a text date into a serial date can be done with the cdate()
function
If you want to test a string before you convert it, you can use isdate()

The current day (in project) is can be found using Activeproject.CurrentDate
It is going to be different in most cases from start. Start date can be a
property of the project and of a task as well.

If you want to know which day all the tasks start

Sub tellMeTheDay()
For Each Task In ActiveProject.Tasks
MsgBox Task.Name & " - " & Weekday(Task.Start)
Next Task
End Sub

or if you want to show the results in the immediate window instead:

Sub tellMeTheDay()
For Each Task In ActiveProject.Tasks
debug.print task.name & " - " & Weekday(Task.Start)
Next Task
End Sub

-Jack Dahlgren
 
R

Ryan Vande

Thank you; worked great

Jack Dahlgren MVP said:
There are many VBA functions that deal with dates.
I would not convert to a string, just keep the serial date.

You can find the day of the week using the "Weekday" function or
"WeekdayName" function.

Converting a text date into a serial date can be done with the cdate()
function
If you want to test a string before you convert it, you can use isdate()

The current day (in project) is can be found using Activeproject.CurrentDate
It is going to be different in most cases from start. Start date can be a
property of the project and of a task as well.

If you want to know which day all the tasks start

Sub tellMeTheDay()
For Each Task In ActiveProject.Tasks
MsgBox Task.Name & " - " & Weekday(Task.Start)
Next Task
End Sub

or if you want to show the results in the immediate window instead:

Sub tellMeTheDay()
For Each Task In ActiveProject.Tasks
debug.print task.name & " - " & Weekday(Task.Start)
Next Task
End Sub

-Jack Dahlgren


Ryan Vande said:
Ok so we extract all our data from excel into a project sheet

We have variables setup as mstask.start which equals ["Start Date"] +
["Start time"]


also same for end date and time but we can sum everything up from the
start
I believe.

Now the format of these dates come out as 1/01/01 <-- Example

I want to make a programable decision based off day of week of the listed
jobs within our project sheet. So weekday(date) would be nice, but wont
this
return the current day. Or can I use weekday(date) against ["Start Date"]
?

I was trying to cstr("Start Date") To try and get this date as a string
and
then I can perform some manipulation on it but I was not getting success.
I
was going to Trim the string and set up a array (Sort of speak)

Would there be an easy way to go through each row and based off "Start
Date"
distinguish which day the date currently falls on? A i heading the right
direction trying to convert this date into a String?

Can I do something like weekday(date #"Start date"#)

Something to that nature?
 

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