cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kostasoul
Advocate I
Advocate I

DateDiff Days Round Up Bug

Hi,

 

We've had some trouble with the DateDiff function when calculating the number of days remaining.  It looks like there is a bug.

 

It appears to take fractional parts of the days and if there is more than half a day remainder, round up the result, which looks like there is an extra day.

 

For example
DateDiff(DateTimeValue("02/03/2020 11:00 PM"),DateTimeValue("02/07/2020 10:00 PM"),Days) should equal 3 but returns 4

 

Looking at the hours, then dividing by 24

DateDiff(DateTimeValue("02/03/2020 11:00 PM"),DateTimeValue("02/07/2020 10:00 PM"),Hours) / 24 

returns 3.9~ which then gets upped to 4, which explains why the bug is occurring.

 

We worked around this bug by using a round down,

RoundDown(DateDiff(timeNow, expiryDate, Hours) / 24,0)

but it took a lot of investigation time.  It appears someone has already raised a similar defect with DateDiff around Years back in 2018 but it doesn't look like it was addressed.

 

To track down the bug we built a datatable in powerapps and compared different ways of calculating the date.  You can see for the dates with a fractional difference above 3.5, things get rounded up for DateDiff days (see the 2nd row and 4th last row)

 

screenshot.png

Whats the best way to lodge this as a bug?  I think having correctness shouldn't be a feature request

 

Best regards

 

Kon

 

 

5 REPLIES 5
v-siky-msft
Community Support
Community Support

@kostasoul 

 

Thanks for your feedback.

I will submit this issue to PowerApps Team and hope it will be fixed in the next Update. If there is any update, I will post back.

Sik

Thanks Sik

If required I could provide a cut down app with just the datatable for testing.

Also discovered that calculations based on hours suffered the same issue (eg if there were greater than 2h 30m remaining), datediff hours would round up and show 3h remaining

Hi @v-siky-msft 

 

Are there any news about this?

 

Thanks,

 

Fernando

 

kostasoul
Advocate I
Advocate I

@v-siky-msft any update on this issue?

I just noticed someone replying to a ideas post from 2018 about it

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/DateDiff-with-units-set-to-years-rounds-to-the-... 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,277)