Skip to Content.
Sympa Menu

freetds - Re: DATETIME problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Stefan Carstens" <s.carstens AT coolspot.de>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: DATETIME problem
  • Date: Wed, 19 Dec 2001 12:11:47 +0100


Hi, I fixed the problem myself.
The thing lies in src/freetds/convert.c, in the function
tds_convert_datetime
I fixed the problem by changing it :
TDS_INT tds_convert_datetime(int srctype,unsigned char *src,int
desttype,unsigned char *dest,TDS_INT destlen)
{
TDS_INT dtdays, dttime;
time_t tmp_secs_from_epoch;

switch(desttype) {
case SYBCHAR:
case SYBVARCHAR:
/* FIX ME -- This fails for dates before 1902 or after 2038
*/
if (destlen<0) {
memset(dest,' ',30);
} else {
memset(dest,' ',destlen);
}
if (!src) {
*dest='\0';
return 0;
}
memcpy(&dtdays, src, 4);
memcpy(&dttime, src+4, 4);
/* begin <lkrauss AT wbs-blank.de> 2001-10-13 */
if (dtdays==0 && dttime==0) {
*dest='\0';
return 0;
}
/* end lkrauss */
tmp_secs_from_epoch = ((dtdays - 25567)*24*60*60) +
(dttime/300);
if (destlen<20) {
strftime(dest, destlen-1, "%b %d %Y
%I:%M%p",
(struct tm*)gmtime(&tmp_secs_from_epoch));
return destlen;
} else {
file://strftime(dest, 20, "%b %d %Y
%I:%M%p",
// Patch by s. sonnenberg-carstens to fix
some nasty conversion errors
strftime(dest, 20, "%Y-%m-%d %H:%M:%S",
(struct tm*)gmtime(&tmp_secs_from_epoch));
return (strlen(dest));
}
break;
case SYBDATETIME:
memcpy(dest,src,sizeof(TDS_DATETIME));
return sizeof(TDS_DATETIME);
break;
case SYBDATETIME4:
break;
default:
return TDS_FAIL;
break;
}
return TDS_FAIL;
}

After applying the patch, the data comes in the same form as it is displayed
by the QueryAnalyzer.
This patch applies to 0.53pre3


----- Original Message -----
From: Stefan Carstens
To: TDS Development Group
Sent: Tuesday, December 18, 2001 12:14 PM
Subject: [freetds] DATETIME problem


We defined some tables with DATETIME types.
If we fetch the data via the SQLAnalyzer we see the correct time,
"12.12.2001:23:34:34.045" for example.
If we do so with PHP's mssql_query, the seconds are missing.
We use freetds 0.53pre3.
What is wrong ?

---
You are currently subscribed to freetds as: [s.carstens AT coolspot.de]
To unsubscribe, forward this message to
$subst('Email.Unsub')





Archive powered by MHonArc 2.6.24.

Top of Page