Skip to main content

Notifications

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))

happyume_0-1715010533577.png

 

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"
)

happyume_1-1715010939886.png

 

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"
)

happyume_2-1715011055292.png

Comments

*This post is locked for comments