Skip to Content.
Sympa Menu

freetds - RE: date format in ODBC

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 franklin.metalab.unc.edu>
  • Subject: RE: date format in ODBC
  • Date: Wed, 31 Jul 2002 17:52:31 -0400


> From: Bill Thompson [mailto:thompbil AT exchange.uk.ml.com]
> Sent: July 31, 2002 11:31 AM
>
> I would like to know the string format that is returned from
> the ODBC api,
> when a datetime column is bound to a character variable (SQL_C_CHAR)

Bill,

Docs on the aforementioned "gadget":

SQLDriverConnect (ODBC)

The Microsoft® SQL Server(tm) ODBC driver and the ODBC driver manager
recognizes the following SQLDriverConnect connection string keywords.

[snip]

Regional
When yes, the SQL Server ODBC driver uses client settings when
converting currency, date, and time data to character data. The conversion
is one way only; the driver does not recognize non-ODBC standard formats for
date strings or currency values within; for example, a parameter used in an
INSERT or UPDATE statement. When no, the driver uses ODBC standard strings
to represent currency, date, and time data that is converted to string data.


---

SQLConfigDataSource (ODBC)
The Microsoft® SQL Server(tm) ODBC driver supports the following SQL
Server-specific keyword/value pairs for data source configuration attribute
strings.

Keyword Values Description
[snip]
Regional yes
Respect client workstation settings for region when converting date,
time, and currency values to character strings. This setting should only be
specified for applications that only display data, not for applications that
process data.

---

SQLSetStmtAttr (ODBC)

[snip]
The SQL Server ODBC driver also supports the following driver-specific
statement attributes.
[snip]

SQL_SOPT_SS_REGIONALIZE
The driver uses this attribute to determine data conversion at the
statement level. The attribute causes the driver to respect the client
locale setting when converting date, time, and currency values to character
strings. The conversion is from SQL Server native data types to character
strings only.

ValuePtr value Description
SQL_RE_OFF Default.
The driver does not convert date, time, and currency data to
character string data using the client locale setting.

SQL_RE_ON
The driver uses the client locale setting when converting date,
time, and currency data to character string data.


Regional conversion settings apply to currency, numeric, date, and time data
types. The conversion setting is only applicable to:

* Output conversions when currency, numeric, date, or time values are
converted to character strings.
* Bulk copy in operations containing character columns when BCP6xFILEFMT is
also set on.

----------------------------------------------------------------------------
----
Note When the statement option SQL_SOPT_SS_REGIONALIZE is on, the driver
uses the locale registry settings for the current user. The driver does not
honor the current thread's locale if the application sets it by, for
example, calling SetThreadLocale.

Altering the regional behavior of a data source can cause application
failure. An application that parses date strings and expects date strings to
appear as defined by ODBC, could be adversely affected by altering this
value.
----------------------------------------------------------------------------
----

+++

All to confirm, as Mr. Harvey said, that the driver *can* convert to a
locale-derived format, but doesn't have to, and won't always in an
unsurprising way. Hope you are as, ahem, amused by this as I am.

I want to mention that MS's default format is ISO-specified. I think that's
another good reason to follow their lead.

Regards,

--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 for certain accounts we do not accept
orders and/or instructions by e-mail, and for those accounts we will not be
responsible for carrying out such orders and/or instructions. Kindly refrain
from sending orders or instructions by e-mail unless you have confirmed that
we accept such communications for your account. Please also note that to
satisfy regulatory requirements we review the outgoing and incoming e-mail
correspondence of staff members serving certain functions.






Archive powered by MHonArc 2.6.24.

Top of Page