[freetds] Status of support for Time type

James K. Lowden jklowden at freetds.org
Tue Apr 30 23:39:01 EDT 2013


On Tue, 30 Apr 2013 20:05:00 +0100
Frediano Ziglio <freddy77 at gmail.com> wrote:

> Problem here is also that you are using dblib which is not supposed
> to be extended!
> 
> As Microsoft decided to not update it we should find a way to
> compatibly extend dblib in order to put/get time/date!

It is easily done, if one has the time.  What needs extending other
than dbbind() and bcp_bind()?  

ISTM dbbind() should support binding a server's DATE or TIME to
DBDATETIME or DBDATETIM4, subject to domain constraints.  Although
there are new types, most databases still keep data per the
Gregorian calendar, and most days are still 24 hours.  Mapping the new
date & time column types to the existing db-lib structures would allow
existing programs to use the new column types merely by relinking to a
newer FreeTDS.  

For completeness -- to support new applications using the extended date
range -- dbbind() would need new structs and new bindings.  

For structures I would use those already defined for ODBC.  Microsoft
defines these, but I don't see support for them in tds_convert()?  

struct tagDATE_STRUCT {
   SQLSMALLINT year;
   SQLUSMALLINT month;
   SQLUSMALLINT day;  
} DATE_STRUCT;

struct tagTIME_STRUCT {
   SQLUSMALLINT hour;
   SQLUSMALLINT minute;
   SQLUSMALLINT second;
} TIME_STRUCT

For binding, dbbind() defines SMALLDATETIBIND and DATETIMEBIND. I would
suggest adding DATEBIND and TIMEBIND.  

Those are needed only for binary bindings, and only if we adopt new
structs. 

Just a small matter of programming.  

--jkl


More information about the FreeTDS mailing list