Loosing last second data when picking a date range. You end times as tmp.setHours(23,59,59,0); should be setHours(23,59,59,999); so that I do not miss the last second of data. Also might have to change constants line 680 - 684 from 86399000 to 86399999.