database query position by user and date range