Skip to Content.
Sympa Menu

freetds - Re: datetime format

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bradley Bell <bradleyb AT u.washington.edu>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: datetime format
  • Date: Mon, 17 Dec 2001 12:55:24 -0800


On Sun, Dec 16, 2001 at 08:11:05PM -0500, James K. Lowden wrote:
> Bradley Bell wrote:
> >
> > Hi, when selecting a datetime value using freetds, I get values such as:
> > "Dec 13 2001 05:58PM"
> > Whereas the same select statement in the MS SQL Query analyzer give:
> > "2001-12-13 17:58:55.000"
> >
> > Since I need to be able to convert back and forth between datetime values
> > and unix timestamps, I need to at least have the number of seconds
> > (millisecs don't matter).
> >
> > Is this a problem in FreeTDS, or a limitation of the TDS protocol, or
> > what?
> > Is it possible to make FreeTDS always return the number of seconds in
> > datetime fields?
>
> Brad,
>
> MS SQL Query Analyzer is an ODBC tool. It's default datetime display is
> controlled by some ODBC settings. I don't know the details.
>
> To illustrate, try Microsoft's isql command-line tool. I think you'll
> find it represents datetimes the way, say, sqsh does.

isql uses db-lib, so maybe this is a limitation of db-lib?

> > (I don't want to use CONVERT, because the select statements in this
> > application should remain portable)
>
> If the server is consistent (always MS SQL Server or Sybase), the most
> portable way probably *is* to coerce the format with convert.

It needs to be portable to several different backends. MS/Sybase is the
only one that seems to need a custom select statement for timestamp/datetime
values. I see that when freetds is being used as an odbc driver, it also
returns: (with unixodbc's isql)
SQL> select getdate();
+--------------------+
| Dec 17 2001 12:28PM|
+--------------------+
That's not right, is it?

-brad

--
Bradley Bell
Computer Support Analyst
University of Washington
Classroom Support Services




Archive powered by MHonArc 2.6.24.

Top of Page