In MS SQL server, there are two date types: datetime and smalldatetime; datetime has a time component and smalldatetime does not. in adodbapi, they both come in as basically the same type and adodbapi converts them both to python's datetime.date if the time component is 0 or to datetime.datetime otherwise. This leads to possible type differences if a datetime column sometimes has a time component of midnight, and sometimes has other times (for some strange reason datetime.date and datetime.datetime are not comparable).
I would prefer that sql datetime get converted to python datetime.datetime (regardless of if the time component), and sql smalldatetime get converted to python datetime.date (with the exception that sql null get converted to None regardless).
Part of the problem of distinguishing these types is that the type_code of both datetime and smalldatetime is 135 (adDBTimeStamp), however they can be distinguished by the scale field of .description - the scale on datetime is 3, whereas the scale on smalldatetime is 0.
Log in to post a comment.