How To get the first and last date of the month for a selected date
1 - First Day of the Month
To obtain the first date of the month, we will use below formula:
DateValue (Month(DatePicker1.SelectedDate) & "/" & "1" & "/" & Year(DatePicker1.SelectedDate))
2 - Last Day of the Month
a First we will calculate first day of the next month
"first Day of Next Month: " & Text(
DateAdd(
DateValue (Month(DatePicker1.SelectedDate) & "/" & "1" & "/" & Year(DatePicker1.SelectedDate)),
1,
TimeUnit.Months
),
"dd-mmm-yyyy"
)
b - We will now subtract one day from first day of next month to arrive at last day of the selected month
"last Day of Selected Month: " & Text(
DateAdd(
DateAdd(
DateValue (Month(DatePicker1.SelectedDate) & "/" & "1" & "/" & Year(DatePicker1.SelectedDate)),
1,
TimeUnit.Months
),
-1,
TimeUnit.Days
),
"dd-mmm-yyyy"
)
*This post is locked for comments