Crystal Reports: FirstMonday() Function

Finds the the first Monday in the current month.

Function FirstMonday (Value As Date) As Date
'first day of the specified month
Dim FirstOfMonth As Date
FirstOfMonth= DateValue(Year(Value), Month(Value), 1)
'Convert the first day to the Monday of the same week
Dim Monday As Date
Monday = FirstOfMonth + (2-DayOfWeek(FirstOfMonth))
'make sure Monday is still in the same month as the first day of the month. If not, adjust.
If Month(Monday) <> Month(FirstOfMonth) Then Monday=Monday+7
'return date
FirstMonday=Monday
End Function

Parameters

Value
The specified month.

Return Value

A date

Remarks

none

Example

'finds the first monday of the current month
FirstMonday(CurrentDate)

Requirements

This function requires the use of Basic Syntax.

Leave a Reply

Your email address will not be published. Required fields are marked *