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

Add days to a different date field

Hi there, I am trying to add 30 days to a datefield. The extra 30 days should be calculated using a different date field. I found a few other topics about this but they seem not to work for me. Especially this topic seems similar to my question. But when I use the same code I get an error. It's Dutch but it's saying it has unexpected characters. 

 

DatePicker 1 corresponds to the field 'Datum uitdienst' and DatePicker2 corresponds to the field 'Datum e-mail verwijderen'. I want DatePicker2 to add 30 days to DatePicker1. DatePicker1 has a default value of Today() to show current day but this date will change once the user starts filling in the form.

date.jpg

 

What am I doing wrong here?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Add days to a different date field

Hi @Ewoud

Looking at your screenshot, it looks like DatePicker1 is a card rather than a date picker control.

Can you expand the DatePicker1 node (the bit highlighted in yellow), and find the name of the date picker? It'll look something like DataCardValueXXXX - similar to the control that I marked in blue.

 

image.png

Next, use this control name in your formula like so and it should hopefully solve the problem.

DateAdd(DataCardValueXXXX.SelectedDate; 30; Days)

 

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Add days to a different date field

Hi @Ewoud

 

Can you replace the commas with semi-colons in your formula, and see if that removes the error?

 

DateAdd(DatePicker1.SelectedDate;30;Days)
Highlighted
Helper II
Helper II

Re: Add days to a different date field

Hi @timl,

 

Thanks for the suggestion. Unfortunately it throws me a different error. Something about an invalid name and not recognizing the ID.

date2.jpg

 

But then I changed the value of Datepicker into the name of the field which is 'Datum uitdienst'. It looks like that works, sort of. As you can see it doesn't add 30 days but just 8 days. And when I fill in the form and change the date of 'Datum uitdienst' nothing happens, and it also shows a default date of 31-12-2001.

 

I also tried to use DataCardValue5 but that also gives an error.

Highlighted
Helper II
Helper II

Re: Add days to a different date field

Sorry, forgot to add the second image.

datum3.jpg

Highlighted
Super User
Super User

Re: Add days to a different date field

Hi @Ewoud

Looking at your screenshot, it looks like DatePicker1 is a card rather than a date picker control.

Can you expand the DatePicker1 node (the bit highlighted in yellow), and find the name of the date picker? It'll look something like DataCardValueXXXX - similar to the control that I marked in blue.

 

image.png

Next, use this control name in your formula like so and it should hopefully solve the problem.

DateAdd(DataCardValueXXXX.SelectedDate; 30; Days)

 

View solution in original post

Highlighted
Helper II
Helper II

Re: Add days to a different date field

Hi @timl,

 

You are a genius. I tried a formula that didn't contain the 'SelectedDate' part. But now that I did it works like a charm.

 

Thank you very much for your help!

Highlighted
Super User
Super User

Re: Add days to a different date field

Thanks @Ewoud! I'm glad the problem is solved.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (5,494)