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.
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)
Whats the best way to lodge this as a bug? I think having correctness shouldn't be a feature request
Check out the on demand sessions that are available now!
ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.
Features releasing from October 2020 through March 2021
Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!