SOLVED

Set default date on DatePicker from a drop down control event

Copper Contributor

Is it possible to have the default date of a date picker control be programmatically set when a user clicks a drop down? I have two controls, DropDown1 and DatePicker 1. What I would like, is when the user clicks the DropDown1, the default date of DatePicker1 changes to 10 days from today's date.

 

TIA,

 

Tom

4 Replies
best response confirmed by TRundle2022 (Copper Contributor)
Solution

@TRundle2022 yes you can set the DefaultDate property to change based on the selection in the dropdown. Make sure you have set the first item in the dropdown to "" then set the DefaultDate property of the date picker to:

If(Dropdown1.Selected.Value <> "",Today()+10,Today())

 

Or you can do something like this to set it to a date based on which item in the dropdown has been selected:

If(Dropdown1.Selected.Value ="Anguilla",Today()+10,If(Dropdown1.Selected.Value= "Antigua",Today()+20, Today()+30))

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

@RobElliott  Thank you. When I used the first formula, it threw an error, 'Value' isn't recognized. I changed the formula to If(Dropdown1.SelectedText.Value <> "",Today()+10,Today()), and that worked.

 

Thank you

@RobElliott 

I am trying to do something similar, but to populate the default date with the text in the drop down.

 

I have a data connection to another list where the user must select from the authorized dates, I'm pulling those dates into a drop down as text. Then I need to update the date with the selection.

 

Dates being pulled into DDdayOne value: Distinct(Filter('Class-Calendar', Category.Value = "Bluebeam" And Today() <= 'Start-Date'),'Start-Date')

 

DatacardValue2-DefaultDate = DDdayOne.SelectedText

 

How do I convert text into date format?

 

@ColleenBristol You can try using DateValue() function in Power apps. Dates must be in one of these formats:

  • MM/DD/YYYY or MM-DD-YYYY
  • DD/MM/YYYY or DD-MM-YYYY
  • YYYY/MM/DD or YYYY-MM-DD
  • MM/DD/YY or MM-DD-YY
  • DD/MM/YY or DD-MM-YY
  • DD Mon YYYY
  • Month DD, YYYY

Example

 

DateValue(inputStartDate.Text)

 

DocumentationDateValue function in Power Apps 


Please consider giving a Like if my post helped you in any way.

1 best response

Accepted Solutions
best response confirmed by TRundle2022 (Copper Contributor)
Solution

@TRundle2022 yes you can set the DefaultDate property to change based on the selection in the dropdown. Make sure you have set the first item in the dropdown to "" then set the DefaultDate property of the date picker to:

If(Dropdown1.Selected.Value <> "",Today()+10,Today())

 

Or you can do something like this to set it to a date based on which item in the dropdown has been selected:

If(Dropdown1.Selected.Value ="Anguilla",Today()+10,If(Dropdown1.Selected.Value= "Antigua",Today()+20, Today()+30))

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

View solution in original post