FIRSTDATE

There are 3 functions.


FIRSTDATE_INTHISWEEK

Returns the date of the first day of a week.

Public Function FIRSTDATE_INTHISWEEK(Optional ByVal dtDateValue As Date) As Long 
    Application.Volatile
    
    FIRSTDATE_INTHISWEEK = dtDateValue - VBA.Weekday(dtDateValue, vbUseSystemDayOfWeek) + 1
End Function

FIRSTDATE_INTHISMONTH

Returns the date of the first day of a month.

Public Function FIRSTDATE_INTHISMONTH(Optional ByVal dtDateValue As Date) As Long 
    Application.Volatile
    If VBA.IsMissing(dtDateValue) Then
        dtDateValue = VBA.Date
    End If

    FIRSTDATE_INTHISMONTH = VBA.DateSerial(VBA.Year(dtDateValue), VBA.Month(dtDateValue), 1)
End Function

FIRSTDATE_INTHISYEAR

Returns the date of the first day of a year.

Public Function FIRSTDATE_INTHISYEAR(Optional ByVal dtDateValue As Date) As Long 
    Application.Volatile
    
    If VBA.IsMissing(dtDateValue) Then
        dtDateValue = VBA.Date
    End If
    
    FIRSTDATE_INTHISYEAR = VBA.DateSerial(VBA.Year(dtDateValue), 1, 1)
End Function


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