I.e. strconv.infer('2017-01-01 00:00:01') returns datetime while strconv.infer('2017-01-01 00:00:00') returns a date. I traced back the issue to if dt.time(): - when dt.time() is 00:00:00 the if returns false and infer a date