Skip to Content.
Sympa Menu

freetds - [freetds] bug: converting to smalldatetime

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "TDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] bug: converting to smalldatetime
  • Date: Wed, 12 May 2004 17:28:23 -0400

If you are using bcp to load dates, you'll want to know about this.

Using freebcp to load this file:

$ head ivr.dat
1063195\03-JAN-00\271.54319615\21\0\21\\\\\
1063195\04-JAN-00\266.56002764\21\0\21\\\\\
1063195\05-JAN-00\258.84445257\21\0\21\\\\\
1063195\06-JAN-00\254.49245866\21\0\21\\\\\
1063195\07-JAN-00\257.83353314\21\0\21\\\\\
[...]

into a table whose second column is smalldatetime, I get

1> select count(*), year(AsOf), min(AsOf), max(AsOf) from ivr group by
year(AsOf) order by year(AsOf)
2> go

----------- ----------- -------------------- --------------------
260 1900 Jan 3 1900 12:00AM Dec 29 1900 12:00AM

If the date string ends in '-99' I get 1999, if '-01' then 2001. But '-00'
is a trip to This Old House.

The error is in src/tds/convert.c::store_year(). Patch attached.

store_year(int year, struct tds_time *t)
{

if (year <= 0) // should be < 0
return 0;

if (year < 100) {
if (year > 49)
t->tm_year = year;
else
t->tm_year = 100 + year;
return (1);

<<convert.c.diff>>
--jkl


-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to
inform and update our clients, prospects and consultants of developments
relating to our services and products, would not like to receive further
e-mail correspondence from the sender, please "reply" to the sender
indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.

Attachment: convert.c.diff
Description: convert.c.diff



  • [freetds] bug: converting to smalldatetime, Lowden, James K, 05/12/2004

Archive powered by MHonArc 2.6.24.

Top of Page