I use the following code to calculate time to retirement. It gives me an answer in Months and Days. Can anyone tell me how to calculate in Weeks and Days?
Thanks in advance for your efforts.
Bob
--------------------------------------------------------
Private Sub Command20_Click()
Dim strInterval As String
Dim Date1 As Date ' (Todays Dats)
Dim Date2 As Date ' (Date of Retirement)
Dim bolShowZero As Boolean
Dim varDiff As Variant
strInterval = ""
Me![ckMonths].SetFocus
If Me![ckMonths] Then
strInterval = strInterval & "m"
End If
Me![ckDays].SetFocus
If Me![ckDays] Then
strInterval = strInterval & "d"
End If
Me![ckZero].SetFocus
If Me![ckZero] Then
bolShowZero = True
End If
Me![txtDate1].SetFocus
If Me![txtDate1].Value <> "" Then
Date1 = Me![txtDate1].Value
Else
MsgBox "Please enter a beginning date."
Exit Sub
End If
Me![txtDate2].SetFocus
If Me![txtDate2].Value <> "" Then
Date2 = Me![txtDate2].Value
Else
MsgBox "Please enter an end date."
Exit Sub
End If
varDiff = Diff2Dates(strInterval, Date1, Date2, bolShowZero)
Me![txtResult].SetFocus
Me![txtResult].Value = varDiff
End Sub
Thanks in advance for your efforts.
Bob
--------------------------------------------------------
Private Sub Command20_Click()
Dim strInterval As String
Dim Date1 As Date ' (Todays Dats)
Dim Date2 As Date ' (Date of Retirement)
Dim bolShowZero As Boolean
Dim varDiff As Variant
strInterval = ""
Me![ckMonths].SetFocus
If Me![ckMonths] Then
strInterval = strInterval & "m"
End If
Me![ckDays].SetFocus
If Me![ckDays] Then
strInterval = strInterval & "d"
End If
Me![ckZero].SetFocus
If Me![ckZero] Then
bolShowZero = True
End If
Me![txtDate1].SetFocus
If Me![txtDate1].Value <> "" Then
Date1 = Me![txtDate1].Value
Else
MsgBox "Please enter a beginning date."
Exit Sub
End If
Me![txtDate2].SetFocus
If Me![txtDate2].Value <> "" Then
Date2 = Me![txtDate2].Value
Else
MsgBox "Please enter an end date."
Exit Sub
End If
varDiff = Diff2Dates(strInterval, Date1, Date2, bolShowZero)
Me![txtResult].SetFocus
Me![txtResult].Value = varDiff
End Sub