UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetLastDayOfMonth    


Get Last Day of Month

' GetLastDayOfMonth
' http://www.utteraccess.com/wiki/GetLastDayOfMonth
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2011-03-27                    
Public Function GetLastDayOfMonth(Optional ByVal pDate)

'110327 Crystal
  'return a date the represents the last day of the month
  'also called the EOM (End Of Month)
  'if no date is passed, the current date is used
  ' examples:
  '    GetLastDayOfMonth("12 dec 2011")
  '    GetLastDayOfMonth(#1/2/2012#)
  '    GetLastDayOfMonth( [myDateField] )
  '    GetLastDayOfMonth()

  If IsMissing(pDate) Then pDate = Date

  'you may wish to remove IsNumeric from the following condition:
  If Not IsDate(pDate) And Not IsNumeric(pDate) Then Exit Function
  GetLastDayOfMonth = DateSerial(Year(pDate), Month(pDate) + 1, 0)

End Function

Creative Commons License
GetLastDayOfMonth by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 32,317 times.  This page was last modified 09:11, 6 April 2011 by Jack Leach. Contributions by strive4peace2011  Disclaimers