Welcome back to my blog. I am back with another blog on Power Apps and this time it’s about a very common requirement. How to get the first and the last date of current month in Power Apps?
Isn’t it too simple a requirement? It is indeed and something which you might come across as a rather common requirement. So let’s see how we can achieve the same.
The first is starting day of the month. It’s actually easy. I am going to use the Today() function to keep everything Dynamic. Below is the formula for the starting date of the month.
$"Start date: {Month(Today())}/01/{Year(Today())}"
Now comes the tough part. The end date of the current month. And below is the formula to do that. If you are looking how to do the same in Power Automate, you can check for the link here.
$"End date: {Month(Today())}/{Day(
DateAdd(
DateAdd(
Today(),
1,
Months
),
-Day(Today()),
Days
)
)}/{Year(Today())}"
Check for the part in italic and bold. A rather complicated formula you shall say. But it’s actually very easy.
Let’s take the inner formula first.
DateAdd(
Today(),
1,
Months
)
I add one month to the current date. This will return the same day of today for the next month. In the outer DateAdd function I use the date returned from the inner DateAdd function and substract the day of the current month to arrive at the last date of the current month.
And below is the result as expected.
Hope this helped. You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.