[freetds] db-lib: support for new MS SQL 2008 data types - part 3

LacaK lacak at zoznam.sk
Mon May 19 07:55:01 EDT 2014


LacaK  wrote / napísal(a):
>
> May be that it is not related, but I noticed that FreeTDS converts 
> "datetimeoffset" to "datetime2" bit different than does SQL Server.
> For example we have any table "t" with "datetimeoffset" column named 
> "dto", with value : '2014-05-19 12:50:00 +01:00'
>
> When I do in SQL Server:
>   select dto, cast(dto as datetime2) as dt2 from t;
>
> I receive:
>   dto                                            dt2
>   ------------------------------------------------------
>   2014-05-19 12:50:00 +01:00   2014-05-19 12:50:00
>
> Which corresponds to: 
> http://msdn.microsoft.com/en-us/library/bb630289.aspx
> Where is stated: "The date and time are copied to the datetime2 value, 
> and the time zone is truncated."
>
> But when I am trying use dbconvert() which calls tds_convert() for 
> srctype=SYBMSDATETIMEOFFSET to desttype=SYBMSDATETIME2 then I receive 
> UTC datetime (shifted by time zone offset)
>
> So converting (casting) in SQL Server is different from that used in 
> FreeTDS ... is it as expected ?
It is okay, as far as there is "offset" field in TDS_DATETIMEALL which 
holds time zone offset in minutes.
I have expected, that when I am converting to SYBMSDATETIME2 then I must 
evaluate only "date" and "time" fields (because datetime2 data type does 
not hold time zone information) ... so I overlooked "offset" field, 
because I have "wrongly" expected, that it will be zero for SYBMSDATETIME2.
So it is okay for me.
Thanks
-Laco.



More information about the FreeTDS mailing list