ISDATE

There are 6 functions


ISDATE_FIRSTOFAWEEK

Returns whether a date is the first day of the week.



ISDATE_FIRSTOFAMONTH

Returns whether a date is the first day of the month.

Public Function ISDATE_FIRSTOFAMONTH(Optional ByVal dtDateValue As Date) As Boolean 
Dim iDay As Integer
    Application.Volatile
    
    If VBA.IsMissing(dtDateValue) Then
        dtDateValue = VBA.Date
    End If
    
    iDay = VBA.Day(dtDateValue)
    If (iDay = 1) Then ISDATE_FIRSTOFAMONTH = True
    If (iDay > 1) Then ISDATE_FIRSTOFAMONTH = False
End Function

ISDATE_FIRSTOFAYEAR

Returns whether a date is the first day of a year


ISDATE_LASTOFAMONTH

Returns whether a date is the last day of the month.

Public Function ISDATE_LASTOFAMONTH(Optional ByVal dtDateValue As Date) As Boolean 
Dim iDay As Integer
Dim iMonth As Integer
Dim iYear As Integer
Dim iNoOfDays As Integer
    Application.Volatile
    
    If VBA.IsMissing(dtDateValue) Then
        dtDateValue = VBA.Date
    End If

    iDay = VBA.Day(dtDateValue)
    iMonth = VBA.Month(dtDateValue)
    iYear = VBA.Year(dtDateValue)
    iNoOfDays = VBA.Day(VBA.DateSerial(iYear, iMonth + 1, 1) - 1)
     
    If (iDay = iNoOfDays) Then ISDATE_LASTOFAMONTH = True
    If (iDay < iNoOfDays) Then ISDATE_LASTOFAMONTH = False
End Function

ISDATE_LASTOFAWEEK

Returns whether a date is the last day of the week.

Public Function ISDATE_LASTOFAWEEK(Optional ByVal dtDateValue As Date) As Boolean 
    Application.Volatile
    
    ISDATE_LASTOFAWEEK = dtDateValue - VBA.Weekday(dtDateValue, vbUseSystemDayOfWeek) + 7
End Function


ISDATE_LASTOFAYEAR

Returns whether a date is the last day of the year.



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext