Power Community

Power Community

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

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Preferred Solution | New feature | Microsoft Dataverse

Click on the below image to navigate to my YouTube Channel. Please like and share your valuable feedback on this...

More Articles Like This

- Advertisement -spot_img