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.
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.
Solved! Go to Solution.
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
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:
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!
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.
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.
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")
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
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.
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
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)
User | Count |
---|---|
133 | |
125 | |
73 | |
70 | |
69 |
User | Count |
---|---|
203 | |
201 | |
64 | |
63 | |
52 |