Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assignment of a Date

Status
Not open for further replies.

laperouse

MIS
Oct 14, 2003
9
US
The way that the code is written now, FirstDate and LastDate are 12:00? When I make FirstDate and LastDate As Strings, they are just empty (""). I am trying to find the very first date in the Project and the very last date in the Project. I really just need help with getting the FirstDate to equal BeginDate and LastDate to equal EndDate.

Dim BeginDate As String
Dim EndDate As String
Dim FirstDate As Date
Dim LastDate As Date

'Inputs the Start Date of the Warranty
ActiveProject.Tasks(j).Start = BeginDate

'Pulls the End Date of the Warranty
Pos4 = InStr(Pos3 + 1, linetext, Separator)
EndDate = Trim(Mid(linetext, Pos3 + 1, Pos4 - (Pos3 + 1)))

'Inputs the End Date of the Warranty
ActiveProject.Tasks(j).Finish = EndDate

'Finds the Beginning and Ending of all warranties
If j = 2 Then
FirstDate = ActiveProject.Tasks(j).Start
LastDate = ActiveProject.Tasks(j).Finish
Else
FirstDate = WarrantyStart(BeginDate, FirstDate)
LastDate = WarrantyEnd(EndDate, FirstDate)
End If

Functions:

Function WarrantyStart(BeginDate, FirstDate)
If BeginDate < FirstDate Then
FirstDate = BeginDate
End If
End Function

Function WarrantyEnd(EndDate, FirstDate)
If EndDate > LastDate Then
LastDate = EndDate
End If
End Function
 
What is "j"? It's never defined, never set, never incremented. Why are you treating dates as strings?

Dim tsk As Task
Dim savStart As Date
Dim savFinish As Date

savStart = #12/31/10#
savFinish = #1/1/80#


For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
If tsk.Start < savStart Then
savStart = tsk.Start
End If
If tsk.Finish > savFinish Then
savFinish = tsk.Finish
End If
End If
Next
MsgBox "start is " & savStart & vbCrLf & "finish is " & savFinish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top