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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Next Quarter Month

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
I am using the DateDif to get the difference between BeginDate and EndDate to return a Count.

Count = DateDiff(DateInterval.Quarter, BeginDate, EndDate)
Count + 1

How do I figure out what the next quarter is to get the first month of that quarter? (StartDate)

Example..
BeginDate = June 15
EndDate = Nov 15

I should have 3 StartDates: June 15, July 1, Oct 1

Count = 3 'Using datediff
'This is in a loop Slice = 1,2,3)
Call GetStartDate(Slice,BeginDate,EndDate,Quarter)

Function GetStartDate(Slice,BeginDate,EndDate,Type) as Date
Select Type
Case Quarter
if Slice = 1 ' this is easy
StartDate = BeginDate
Else
If StartDate.Month < 4 Then
StartDate = DateSerial(BeginDate.Year, 4, 1)
ElseIf StartDate.Month > 4 And StartDate.Month < 7 Then
StartDate = DateSerial(BeginDate.Year, 7, 1)
ElseIf StartDate.Month > 7 And StartDate.Month < 9 Then
StartDate = DateSerial(BeginDate.Year, 9, 1)
End If
End If

This only works if count returned from date diff is 2. How in the world would you figure out the begin month of the next quarter when begin date can be anything.

Thanks in advance for any help you can provide me!
 
If you just want to return a string of which month the next quarter would be for a certain date, you could just use something like:
Code:
    Private Function GetNextQuarter(ByVal StartDate As Date) As String
        Dim intMonth As Integer = StartDate.Month

        Select Case intMonth
            Case 1 To 3
                Return MonthName(4)
            Case 4 To 6
                Return MonthName(7)
            Case 7 To 9
                Return MonthName(10)
            Case 10 To 12
                Return MonthName(1)
        End Select
    End Function

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top