I'm trying to give a user the number of days beginning with the date the user provides up until today. I'll attach the code, but am really lost in trying to find the number of days in between the first month and this month. I'm sure there is a much cleaner way to do the other parts and am more than happy to consider one! I did perform a search, but no luck... Thanks in advance!
Code:
----------------------------
option explicit
Sub Main
Dim finalDay, rcvdYear as String, finalYear as String, numDyFirst
Dim getDy as String, numDy as double, daysPerPeriod , FnumMo, FnumYr, numDaylast
Dim getYr as String, numYr as Double, cNumYr , InDt as String, finalMonth as String
Dim getMo as String, numMo as double, todDate as String, rcvdMonth as String
Dim ckDy as Integer, totalDy as String, calendarfirstape as string, rcvdDay
Dim daysBetween as Double, numdays, msg1 as String
'WHAT IS THE RECEIVED DATE OF THE RETURN
InDt = InputBox("Enter return received date.")
InDt = Format(InDt, "mm/dd/yyyy")
'WHAT IS TODAY'S DATE
todDate =DateValue(Date$)
todDate = DateValue(Date$)
'PARSE RECEIVED AND TODAY'S (final) DATE
rcvdMonth = Format( Mid(InDt, 1, 2 ), "00")
finalMonth = Format(Mid(todDate, 1, 2 ), "00")
rcvdDay =Format( Mid(InDt, 4, 2 ), "00")
finalDay = Format(Mid(todDate, 4, 2), "00")
rcvdYear = Mid(InDt, 7, 4 )
finalYear = Format(Mid(todDate, 7, 4))
'DETERMINE HOW MANY DAYS ARE IN THE BEG DATE'S MONTH
Select Case rcvdMonth
Case "03", "05", "07", "08", "10", "12"
'TOTAL DYS THESE MONTHS
totalDy = "31"
Case "01"
'TOTAL DYS THIS MONTH
totalDy = "31"
Case "02"
'TOTAL DYS THIS MONTH
totalDy = "28"
Case "04", "06", "09", "11"
'TOTAL DYS THIS MONTH
totalDy = "30"
Case Else
msgbox "Problems with month selct cAsE."
End Select
'ADD NUMBER OF DAYS IN THE RCVD MONTH
numDyFirst = val(totalDy)- rcvdDay
'---------------------------------------------------------------------
'FIND NUMBER OF DAYS SO FAR THIS MONTH
Select Case finalMonth
Case "03", "05", "07", "08", "10", "12"
'TOTAL DYS THESE MONTHS
totalDy = "31"
Case "01"
'TOTAL DYS THIS MONTH
totalDy = "31"
Case "02"
'TOTAL DYS THIS MONTH
totalDy = "28"
Case "04", "06", "09", "11"
'TOTAL DYS THIS MONTH
totalDy = "30"
Case Else
msgbox "Problems with month selct cAsE."
End Select
'DETERMINE NUMBER OF DAYS FINAL MONTH
numDaylast = val(totalDy)- finalDay
'---------------------------------------------------------------------
Need help here!
'DETERMINE NUMBER OF DAYS FOR THE MONTHS IN BETWEEN
daysBetween =
'---------------------------------------------------------------------
numdays = numDyFirst + numDaylast + daysBetween
msg1 = "For the date you entered of: " & Chr$(13) & Chr$(10)
msg1 = msg1 & "you have " & numdays & " already."
msgbox msg1
End Sub
Code:
----------------------------
option explicit
Sub Main
Dim finalDay, rcvdYear as String, finalYear as String, numDyFirst
Dim getDy as String, numDy as double, daysPerPeriod , FnumMo, FnumYr, numDaylast
Dim getYr as String, numYr as Double, cNumYr , InDt as String, finalMonth as String
Dim getMo as String, numMo as double, todDate as String, rcvdMonth as String
Dim ckDy as Integer, totalDy as String, calendarfirstape as string, rcvdDay
Dim daysBetween as Double, numdays, msg1 as String
'WHAT IS THE RECEIVED DATE OF THE RETURN
InDt = InputBox("Enter return received date.")
InDt = Format(InDt, "mm/dd/yyyy")
'WHAT IS TODAY'S DATE
todDate =DateValue(Date$)
todDate = DateValue(Date$)
'PARSE RECEIVED AND TODAY'S (final) DATE
rcvdMonth = Format( Mid(InDt, 1, 2 ), "00")
finalMonth = Format(Mid(todDate, 1, 2 ), "00")
rcvdDay =Format( Mid(InDt, 4, 2 ), "00")
finalDay = Format(Mid(todDate, 4, 2), "00")
rcvdYear = Mid(InDt, 7, 4 )
finalYear = Format(Mid(todDate, 7, 4))
'DETERMINE HOW MANY DAYS ARE IN THE BEG DATE'S MONTH
Select Case rcvdMonth
Case "03", "05", "07", "08", "10", "12"
'TOTAL DYS THESE MONTHS
totalDy = "31"
Case "01"
'TOTAL DYS THIS MONTH
totalDy = "31"
Case "02"
'TOTAL DYS THIS MONTH
totalDy = "28"
Case "04", "06", "09", "11"
'TOTAL DYS THIS MONTH
totalDy = "30"
Case Else
msgbox "Problems with month selct cAsE."
End Select
'ADD NUMBER OF DAYS IN THE RCVD MONTH
numDyFirst = val(totalDy)- rcvdDay
'---------------------------------------------------------------------
'FIND NUMBER OF DAYS SO FAR THIS MONTH
Select Case finalMonth
Case "03", "05", "07", "08", "10", "12"
'TOTAL DYS THESE MONTHS
totalDy = "31"
Case "01"
'TOTAL DYS THIS MONTH
totalDy = "31"
Case "02"
'TOTAL DYS THIS MONTH
totalDy = "28"
Case "04", "06", "09", "11"
'TOTAL DYS THIS MONTH
totalDy = "30"
Case Else
msgbox "Problems with month selct cAsE."
End Select
'DETERMINE NUMBER OF DAYS FINAL MONTH
numDaylast = val(totalDy)- finalDay
'---------------------------------------------------------------------
Need help here!
'DETERMINE NUMBER OF DAYS FOR THE MONTHS IN BETWEEN
daysBetween =
'---------------------------------------------------------------------
numdays = numDyFirst + numDaylast + daysBetween
msg1 = "For the date you entered of: " & Chr$(13) & Chr$(10)
msg1 = msg1 & "you have " & numdays & " already."
msgbox msg1
End Sub