Skip to Content.
Sympa Menu

freetds - RE: Problem with Dates

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'TDS Development Group'" <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Problem with Dates
  • Date: Tue, 27 Aug 2002 16:28:47 +0100


Hi all,

The problem stems from my attempt to implement a common "date cracking"
utility for use in dblib (dbdatecrack), ctlib (cs_date_crack), and ODBC (for
returning data into timestamp variables).
Nice idea I guess, but alas my first attempt has been thwarted by *slightly*
different requirements for these three api's...

In a nutshell, the sybase manuals for dbdatecrack say the returned structure
should be :

typedef struct dbdaterec
{
long dateyear; /* 1900 to the future */
long datemonth; /* 0 - 11 */
long datedmonth; /* 1 - 31 */
long datedyear; /* 1 - 366 */
long datedweek; /* 0 - 6 */
long datehour; /* 0 - 23 */
long dateminute; /* 0 - 59 */
long datesecond; /* 0 - 59 */
long datemsecond; /* 0 - 997 */
long datetzone; /* 0 - 127 */
} DBDATEREC;

Note month is an offset, not the intuitive value.

whereas the SQL server manual page for dbdatecrack says it should be :

typedef struct dbdaterec
{
int year; // 1753 - 9999
int quarter; // 1 - 4
int month; // 1 - 12
int dayofyear; // 1 - 366
int day; // 1 - 31
int week; // 1 - 54 (for leap years)
int weekday; // 1 - 7 (Mon. - Sun.)
int hour; // 0 - 23
int minute; // 0 - 59
int second; // 0 - 59
int millisecond; // 0 - 999
} DBDATEREC;

Note the differences - the month and the day of the week are not offsets but
proper values,
also addition of the "quarter" and "week" fields. ( These may be recent
additions to the MS implementation )

I presume that the ODBC timestamp variable follows the MS datecrack standard
for the month field.

I'll fix this, and I might add the quarter and week fields too, if no-one
objects.

regards,

Bill

> -----Original Message-----
> From: Paul Rensing [SMTP:paul.rensing AT att.net]
> Sent: Tuesday, August 27, 2002 3:43 PM
> To: TDS Development Group
> Subject: [freetds] Problem with Dates
>
> TDSers,
>
> I just tried today's nightly build and found a problem. I am using
> FreeTDS->unixODBC->Python mxODBC. I have a July build (not sure the
> exact date) which works reasonably, except that the column names get
> truncated (not FreeTDS's problem as far as I know).
>
> The problem with the latest build is that the month in time stamps seems
> to be off by one ("6" instead of "7") when fetching a column. My old
> July build works fine.
>
> Any hints?
>
> Paul Rensing
>
>
>
>
>
>
>
> ---
> You are currently subscribed to freetds as: [thompbil AT exchange.uk.ml.com]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')





Archive powered by MHonArc 2.6.24.

Top of Page