cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gjayne84
Frequent Visitor

Calculate date field based on another date

Hi everyone I am customizing a SharePoint list form using PowerApps and have so far been unable to do the following. I have two date fields - Date 1 and Date 2. When a user enters a date into Date 1 I want Date 2 to be automatically populated with a date that is 30 days after Date 1. Is this possible, and if so, how do I do it? Thanks in advance for your help.
1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @gjayne84,

Based on the needs you provided, I think the DateAdd function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:13.JPG

Set the DefaultDate property of the second DatePicker control to following:

DateAdd(DatePicker1.SelectedDate,30,Days)

On your side, you should set the DefaultDate proeprty of the DatePicker control within the Date 2 Data card to following:

DateAdd(DatePicker1.SelectedDate,30,Days)

More details about the DateAdd function, please check the following article:

DateAdd function

 

In addition, you could also consider take a try to set the OnChange property and OnSelect of the DatePicker control within the Date 1 Data card to following:

Set(PopulatedDate, DateAdd(DatePicker1.SelectedDate,30,Days))

Set the DefaultDate proeprty of the DatePicker control within the Date 2 Data card to following:

PopulatedDate

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
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

4 REPLIES 4
Mike8
Memorable Member
Memorable Member

Hello, You can try this: Datepicker2.DefaultDate = DateAdd(DatePicker1.SelectedDate,30,Days)
v-xida-msft
Community Support
Community Support

Hi @gjayne84,

Based on the needs you provided, I think the DateAdd function could achieve your needs.

I have made a test on my side, please take a try with the following workaround:13.JPG

Set the DefaultDate property of the second DatePicker control to following:

DateAdd(DatePicker1.SelectedDate,30,Days)

On your side, you should set the DefaultDate proeprty of the DatePicker control within the Date 2 Data card to following:

DateAdd(DatePicker1.SelectedDate,30,Days)

More details about the DateAdd function, please check the following article:

DateAdd function

 

In addition, you could also consider take a try to set the OnChange property and OnSelect of the DatePicker control within the Date 1 Data card to following:

Set(PopulatedDate, DateAdd(DatePicker1.SelectedDate,30,Days))

Set the DefaultDate proeprty of the DatePicker control within the Date 2 Data card to following:

PopulatedDate

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ninjasword341
New Member

This is great information. I have a different scenario I need help with, if anyone has any ideas

 

Three total fields for a device purchase date, years covered for warranty, and expiration date.

 

So basically if purchase date is 5/5/2020 selected from date picker, with a (2) for 2 years entered numerically in second field. I need the third expiration date in the third field to auto-calculate expiration date at 5/5/2022.

 

Any takers?

Benmo33
Frequent Visitor

Hi, what should I do if my number of days will be different based on dropdown selected value?

for example: if my drop down selected value is ABC then add 14 days and  if my drop down selected value is XYZ then add 30 days.

 

Thank you

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

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