bradleyb at u.washington.edu
Mon Dec 17 15:55:24 EST 2001
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?
> 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?
Computer Support Analyst
University of Washington
Classroom Support Services
More information about the FreeTDS