system.tag.queryTagHistory() returns row outside defined range

Hi,

I am running into strange problem where i query tag history for multiple time segments, and I am getting rows that are not in that specific range. If my time segments are back to back, i get duplicate values.

#####  Wed Nov 19 16:39:08 CET 2025///Wed Nov 19 16:51:23 CET 2025
Wed Nov 19 16:42:31 CET 2025 9.39999961853
Wed Nov 19 16:44:35 CET 2025 9.30000019073
Wed Nov 19 16:45:37 CET 2025 9.39999961853
Wed Nov 19 16:47:10 CET 2025 9.5
Wed Nov 19 16:48:12 CET 2025 9.39999961853
Wed Nov 19 16:49:02 CET 2025 9.5
Wed Nov 19 16:49:32 CET 2025 9.10000038147
Wed Nov 19 16:50:34 CET 2025 9.19999980927
Wed Nov 19 16:51:06 CET 2025 9.10000038147
Wed Nov 19 16:54:12 CET 2025 9.30000019073
#####  Wed Nov 19 16:51:23 CET 2025///Wed Nov 19 17:42:53 CET 2025
Wed Nov 19 16:54:12 CET 2025 9.30000019073
Wed Nov 19 16:54:42 CET 2025 9.19999980927
Wed Nov 19 16:57:18 CET 2025 9.30000019073
Wed Nov 19 16:57:48 CET 2025 9.19999980927
Wed Nov 19 16:58:19 CET 2025 9.30000019073
Wed Nov 19 16:58:43 CET 2025 9.19999980927
Wed Nov 19 16:59:04 CET 2025 9.30000019073
Wed Nov 19 17:51:54 CET 2025 8.89999961853

Last row in each of these two segments are outside of specified bounds.

This is the code i run:

for load in loads:
	
	start_date = load["started_date"]
	end_date = load["ended_date"] or system.date.now()
	
	weight_ds = system.tag.queryTagHistory(
		paths=TAGS, 
		startDate=start_date, 
		endDate=end_date,
		includeBoundingValues=False,
		preventInterpolation=False
	)
	
	print("#####  " + str(start_date) + "///" + str(end_date))
	for w in system.dataset.toPyDataSet(weight_ds):
		print w[0], w[1]

Am I missing something?

Based on searches, would appear that this behaviour has been cited many times, but I have not seen a solution.

Have you tried with Interpolation set to True? Maybe it’s retrieving the last values necessary for interpolation.

Yes.

Can I assume that there will always be one row for interpolation?

Yes, both True and False have no effect on the result.

Not sure. Discrete deadband style might not.