need2progm
Programmer
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!
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!