Title: firstday and lastday of previous month
Here are a couple functions that should do the trick.  Passing the Now() date is optional, as the function assumes you are talking about last month in relation to today's date.
 
Function FirstOfPreviousMonth(Optional dteDate As Date) As Date
   If CLng(dteDate) = 0 Then
     dteDate = Date
   End If
   FirstOfPreviousMonth = DateSerial(Year(dteDate), Month(dteDate) - 1, 1)
End Function

Function LastOfPreviousMonth(Optional dteDate As Date) As Date
   If CLng(dteDate) = 0 Then
     dteDate = Date
   End If
   LastOfPreviousMonth = DateSerial(Year(dteDate), Month(dteDate), 0)
End Function
 
Example use:
    dteFromDate = FirstOfPreviousMonth()
    dteToDate = LastOfPreviousMonth()
 
 
Kevin Meagher
Mid-Columbia Medical Center - Information Systems


>>> [EMAIL PROTECTED] 2/7/2006 7:05 AM >>>

Hello Everyone,

I am working on an issue with the first day of the previous month and the last day of the preview month and enter those into fields.

I have found some things using the DateAdd function and am working on how to take the now date and  get the first and last day's of last month.

I will post my code once I get it closer to a workable product.  If anyone has some references that would be helpful.

Thanks,
Dwight Shuler

Reply via email to