DateDiff dates issue

I’m getting incorrect results when using DateDiff. If i do the following, i get the same result (== 5) when they should equal 6 and 5

DateDiff("d" , "2020-10-04", "2020-10-10")
DateDiff("d" , "2020-10-05", "2020-10-10")

What is causing this?


Daylight savings issue. Only 23 hours between the dates, or 25 depending on your hemisphere. I use round(datediff(“h”, d1, d2) *24},0) or something to that effect. Takes care of the daylight savings change over

That makes sense, thanks.
Though I think it should be
round(datediff("h", d1, d2) /24},0)

Copy from an older thread:
I wrote apps which need and do exact calculations of dates with adding and subtracting days and months. Never cared about setting to midnight.

There are several libraries which provide exact date calculations. It seems important to have a library which provides locales as well.

Currently I prefer to use moment.js. My extraheaders property e.g. would contain:

<script type="text/javascript" src="ted/moment-with-locales.min.js"></script>
<link rel="stylesheet" href="ted/tempusdominus-bootstrap-4.min.css" type="text/css" />
<script type="text/javascript" src="ted/tempusdominus-bootstrap-4.min.js"></script>
<link rel="stylesheet" href="css/all.css" type="text/css" />
<script type="text/javascript" src="js/all.js"></script>"

moment-with-locales.min.js enables to set the locale e.g. to “de_DE” which is done in datepicker settings.

tempusdominus provides a nice datepicker which works together with bootstrap 4.

Adding days and getting the precise new date would work like this:

datum2 = moment(datum1, "DD.MM.YYYY").add(vTageZahl, 'days').toDate();

I’ll my vote for moment as well. The time spent learning it is paid back by not having case after case of date wierdness.

Thanks for your suggestions.