stats: fix a couple of bugs (date.next and extract_value)