cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
azeesdinu Helper II
Helper II

Get Today Date when Dropdown change

I have to calculate the number of days between two dates. Say Date 1 and Date 2. 

I have status dropdown with list of values below in SharePoint custom list. 

  1. New
  2. Appoved to Start
  3. InProduction
  4. Canceleld

I need to get the Date 1 value when status chnaged "Appoved to Start"  and get the Date 2 Value when status chnaged to "InProduction" or "Canceleld". 

 

Could you please help me how impletement this.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Get Today Date when Dropdown change

Hi @azeesdinu ,

Do you want to set the datepicker's value to today if Date 1 is null and Change Status selected "Approved to Start" ?

Is Date1's data type date?

Please try this formula:(set the date picker's DefaultDate)

If(Date1=""&& ddlStatus.selected.Value ="Approved to Start", Today())

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
ajennings1 Resolver I
Resolver I

Re: Get Today Date when Dropdown change

@azeesdinu,

 

Finding the difference between dates is very simple in PowerApps by using the 'DateDiff' function.

 

Lets say you have 2 date picker controls and a textbox that contains the days difference like so:

Capture.PNG

 

In the Default property of the textbox or label where you want the difference, simply use 'DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate)' where the first argument in your case would be the 'Approved to start' date and the second argument is the second date.

 

Hope this helps!

 

azeesdinu Helper II
Helper II

Re: Get Today Date when Dropdown change

Hi ajennings1 

Thanks for your reply.

I need to get the current date in Date 1 field when dropdown selected value is "Appoved to Start" and once we set the current date it's shoud not be updated. Same way I need to get the Date 2 field also. 

 

ajennings1 Resolver I
Resolver I

Re: Get Today Date when Dropdown change

@azeesdinu ,

 

Can I see an example layout of your app form, just so i can see the fields?

ajennings1 Resolver I
Resolver I

Re: Get Today Date when Dropdown change

@azeesdinu,

 

I understand now. You could set a variable which will get todays date when the drop down value equals whatever value you need. 

An example of this rule could be like so: (on a button select perhaps?)

 

'If(DropDown1.SelectedText.Value = "Approved to Start"', Set(ApprovedDate, Now())'

Then when you select another value in the drop down, you can use the same If statment to Set other variables.

 

Hope this helps.

azeesdinu Helper II
Helper II

Re: Get Today Date when Dropdown change

Hi ajennings1,

Thanks again for your reply.  

I need to set the Date 1 value only when it's null and Change Status selected "Approved to Start" 

If did not check the null then it Now() will replace whenever edit the item.

So I tried  with following code in Date field DefaultCode event

If(And(Date1="", ddlStatus.selected.Value ="Approved to Start"), Today(),"") But it's throwing circular reference exception. 

So I need to check the Date 1 value before update otherwise Date 1 field value always replaced whenever update the other  fields with Change status selected item is “Approved to Start")

Community Support
Community Support

Re: Get Today Date when Dropdown change

Hi @azeesdinu ,

Do you want to set the datepicker's value to today if Date 1 is null and Change Status selected "Approved to Start" ?

Is Date1's data type date?

Please try this formula:(set the date picker's DefaultDate)

If(Date1=""&& ddlStatus.selected.Value ="Approved to Start", Today())

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

azeesdinu Helper II
Helper II

Re: Get Today Date when Dropdown change

Thanks for your reply, 
There is type mismatch when we compare Date 1="" since Date 1 is DateTime picker field.
If I use text field for storing Date 1 then I recived Circular refernce issue.

Note : I no need to display the Date 1 and Date 2 feilds. It's hidden.

 

Community Support
Community Support

Re: Get Today Date when Dropdown change

Hi @azeesdinu ,

Please try this formula:

If(IsBlank(Gallery1.Selected.date1)&& ddlStatus.selected.Value ="Approved to Start",Today(),Parent.Default)

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
azeesdinu Helper II
Helper II

Re: Get Today Date when Dropdown change

Hi,

I compare with Datcard Value field, So IsBlank() was not working.  I have update code like belowand its working as expected. Thank you all

If(IsBlank(Date1) && ddlChangeStatus.Selected.Value ="Approved to Start", Today(), Date 1)

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,856)