[freetds] SQLBindParameter using TIMESTAMP_STRUCT: Fractional partis wrong

Sebastien FLAESCH sf at 4js.com
Tue Jan 8 06:48:13 EST 2008


Just tested, works fine now.
Seb

ZIGLIO, Frediano, VF-IT wrote:
>> I believe that the fractional part is wrong inserted when 
>> using the TIMESTAMP_STRUCT type:
>>
>>      rcode = SQLBindParameter(m_hstmt1, 1, SQL_PARAM_INPUT,
>>                               SQL_C_TYPE_TIMESTAMP, 
>> SQL_TYPE_TIMESTAMP, 23, 0,
>>                               &v_ts, 0, &v_ts_ind);
>>
>> In ODBC, the "fraction" field of a TIMESTAMP_STRUCT 
>> represents a number of nanoseconds.
>> -> The value for a half second would be 500,000,000.
>>
>> In Transact-SQL, datetime columns have fraction part 
>> expressed in milliseconds, with an
>> accuracy of 3,33 milliseconds.
>>
>> So when inserting a datetime value with the string 
>> 'yyyy-mm-dd hh:mi:se.003', it means
>> 3 milliseconds, which should be:
>>
>>    3 * 1000 * 1000 = 3,000,000 nanoseconds
>>
>> ... in a TIMESTAMP_STRUCT. Right?
>>
>> But when using this value in a TIMESTAMP_STRUCT binding, I 
>> get .000 in the database.
>>
>> Looks like the value is rounded before it is sent to the server...
>>
>> Note that the value of 18,000,000 nanoseconds (18 
>> milliseconds = .018) is rounded to
>> .017 in the database (as expected)...
>>
>> See attached example to reproduce...
>>
>>
>> Resources:
>>
>> http://msdn2.microsoft.com/en-us/library/ms714556.aspx
>> http://support.microsoft.com/kb/263872
>>
>>
>> Thanks
>> Seb
>>
> 
> Fixed. Was a rounding problem.
> 
> freddy77
> 
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
> 



More information about the FreeTDS mailing list