cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
a10703ant
Helper I
Helper I

Dropdown to force date picker range selectiom

It's possible to have a dropdown with year and month and force the datepicker range?

 

example: 

 

a10703ant_0-1643204008440.png

 

ex: If i select Month January and year 2021 the filter datepicker range its 1/1/2021 to 31/01/2021

 

it's possible to force ?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@a10703ant 

Yes, you just need to have the DefaultDate property of the date picker be the value you want.

 

Ex.  DatePicker1 DefaultDate property formula:

    Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1)

 

Your DatePicker2 DefaultDate property formula:

    DateAdd(DateAdd(Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1), 1, Months), -1, Days)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@a10703ant 

Yes, you just need to have the DefaultDate property of the date picker be the value you want.

 

Ex.  DatePicker1 DefaultDate property formula:

    Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1)

 

Your DatePicker2 DefaultDate property formula:

    DateAdd(DateAdd(Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1), 1, Months), -1, Days)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

What means the function for i understand the syntax?

 

yourMonthDropDown.Selected.Value, 1) why 1?

 

 yourMonthDropDown.Selected.Value, 1), 1, Months), -1, Days) and why 1 Months and -1 days?

 

thanks

 

 

RandyHayes
Super User
Super User

@a10703ant 

The Date function expects three parameters, the year, the month and the day.  So, the formula:

   Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1)

will produce a date that is the first day of the selected year and month.

 

For the second datepicker, you wanted the last day of the month.  So, the trick is to add 1 month to the first day of the month and then subtract 1 day.  That will be the last day of that month.

DateAdd(DateAdd(Date(yourYearDropDown.Selected.Value, yourMonthDropDown.Selected.Value, 1), 1, Months), -1, Days)

So in the above formula, we again get the Year, Month and Day 1 date, and then add 1 month to it and subtract 1 day from it.  That's the last day.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,985)