cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Resolver I
Resolver I

Calculating a DateDiff

Hi,

I'm currently trying to write the date that is 91 days from my end date (which is set in a variable).

My variable varPayPeriodSelectedDropdownEndDate = 3/31/2022

 

I have written this code to start but not sure how to get the return date...

DateValue(DateDiff(Today(), varPayPeriodSelectedDropdownEndDate)-91)

This gives me a value of 1/1/1990?

I would like to SET the datediff value in a variable as well to be used later.

 

Appreciate your support 🙂

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@TB05 

The formula is correct.  But for something else...my bad for not noticing.

The formula should be:

DateAdd(varPayPeriodSelectedDropdownEndDate, -91)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@TB05 

Please consider changing your Formula to the following:

DateAdd(Today(), varPayPeriodSelectedDropdownEndDate, -91)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Nogueira1306
Super User
Super User

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

 

DateDiff(Today(), DateAdd(varPayPeriodSelectedDropdownEndDate,-91,Days), Days)

 

That should get you the diference. It will return an int (1, 2, 3, 4, etc)

 

To set that in a var:

 

Set(varDiference, DateDiff(Today(), DateAdd(varPayPeriodSelectedDropdownEndDate,-91,Days), Days))

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,

Gonçalo Nogueira

Check my LinkedIn!

Buy me a coffee!

Check my User Group (pt-PT)!

Last Post on Community

My website!

Thank you for your quick response, the label field returns a blank entry:

TB05_0-1648653572963.pngTB05_1-1648653591246.png

 

@TB05 

The formula is correct.  But for something else...my bad for not noticing.

The formula should be:

DateAdd(varPayPeriodSelectedDropdownEndDate, -91)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,724)