Set canvas PowerApp date to the last day of the month
When working with canvas PowerApps, you may have a need to have some date ranges set by default. A typical scenario might be where you have 2 date filters and you want to show records that occured between those date ranges. A scenario I had to work with recently was where the customer required the default filter dates to be the first day of the current month and the last day of the current month.
The tricky part is getting the last day of the month. How do we know if its got 30 days or 31? What about the month of February?? What happens in a leap year!?
Turns out there is a handy undocumented “feature” when you use the Date function. If you set the day property to the number 0, it would return the last day of the previous month. So if I wanted to get the last day of February for example, my function would look as follows:
Binding that variable to a date control I had, I was able to get the last day of February accurately!
Hope this helps.