Posted By

corydeppen on 06/23/08


Tagged

access vba 2003 vb


Versions (?)

Last Day of the Month


 / Published in: Visual Basic
 

  1. Function LastDayOfMonth(MonthNbr As Byte, YearNbr As Integer) As Date
  2.  
  3. Dim theDay As Byte
  4.  
  5. For theDay = 1 To 32
  6. If Not IsDate(MonthNbr & "/" & theDay & "/" & YearNbr) Then
  7. theDay = theDay - 1
  8. LastDayOfMonth = CDate(MonthNbr & "/" & theDay & "/" & YearNbr)
  9. Exit Function
  10. End If
  11. Next theDay
  12.  
  13. End Function

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: n8osapi on September 16, 2008

Function LDoM(ByVal d As Date) As Date Dim tmpDate As Date

'Get First Day of Month
tmpDate = DateAdd("d", (Day(d) - 1) * -1, d)

'Get First Day of Next Month
tmpDate = DateAdd("m", 1, tmpDate)

'Get Last Day of This Month
tmpDate = DateAdd("d", -1, tmpDate)

LDoM = tmpDate

End Function

You need to login to post a comment.