RE: DateAdd problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



=MonthEndDate(DateAdd("m",-3,[text0]))

Function MonthEndDate(dtmBaseDate As Date) As Date
Dim intCurrMonth As Integer

intCurrMonth = DatePart("m", dtmBaseDate)
While DatePart("m", dtmBaseDate) = intCurrMonth
dtmBaseDate = DateAdd("d", 1, dtmBaseDate)
Wend
MonthEndDate = DateAdd("d", -1, dtmBaseDate)
End Function


"RussG" wrote:

> In the following expression, Access is not giving me the month-end date:
> =DateAdd("m",-3,[text0])
>
> For example, if [text0]= #3/31/05# the result is 12/31/04, BUT if
> [text0]=#6/30/04# the result is 3/30/04 (I thought Access would automatically
> return 3/31/04). What the heck!
> As always, thanks for the help!
> Russ
.