MartyConnelly
martyconnelly at shaw.ca
Tue Jan 4 16:43:53 CST 2005
You could try some variation of this code
but just remember a companies fiscal year or quarter may not corespond
with a calendar year
In fact it probably won't.
Function dhFirstDayInQuarter( _
Optional dtmDate As Date = 0) As Date
' Returns the first day in the quarter specified
' by the date in dtmDate.
Const dhcMonthsInQuarter As Integer = 3
If dtmDate = 0 Then
' Did the caller pass in a date? If not, use
' the current date.
dtmDate = Date
End If
dhFirstDayInQuarter = DateSerial( _
Year(dtmDate), _
Int((Month(dtmDate) - 1) / dhcMonthsInQuarter) * _
dhcMonthsInQuarter + 1, _
1)
End Function
Function dhLastDayInQuarter(Optional dtmDate As Date = 0) As Date '
'Returns the last day in the quarter specified
' by the date in dtmDate.
Const dhcMonthsInQuarter As Integer = 3
If dtmDate = 0 Then
' Did the caller pass in a date? If not, use
' the current date.
dtmDate = Date
End If
dhLastDayInQuarter = DateSerial( _
Year(dtmDate), _
Int((Month(dtmDate) - 1) / dhcMonthsInQuarter) _
* dhcMonthsInQuarter + (dhcMonthsInQuarter + 1), 0)
End Function
Christopher Hawkins wrote:
>Hello all. Fun VBA question here.
>
> Given a date, how would you determine if it fell within the current calendar quarter?
>
> -Christopher-
>
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada