Fix bug in selecting hours from datetime