Fix query when time range filter is used alone