Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Datetime formats

0 views
Skip to first unread message

Ian

unread,
Jul 24, 2001, 12:08:30 PM7/24/01
to
In my new installation of SQL server 7 SP1 the datetime format is
YYYY-MM-DD HH:MM:SS.00 The extra .00 is playing havoc with my
applications, how can I modify the default format for all users of the
database?

Thanks in advance,
Ian

BP Margolin

unread,
Jul 24, 2001, 1:43:27 PM7/24/01
to
Ian,

SQL Server does NOT have a default datetime format. Datetimes are stored as
numeric offsets from a base date.

The datetime format you are seeing is the default datetime format used by
the connection protocol ... ODBC / OLE DB (ADO). Since this is external to
SQL Server there is no setting within SQL Server that can control this.

You can however create views on your tables, and in the view convert the
datetime to a character format that is suitable for your users /
application. For example, something like:

CREATE TABLE Ian (c1 datetime NOT NULL)
INSERT INTO Ian VALUES (getdate( ))
GO

CREATE VIEW v_Ian AS
SELECT c1 = CONVERT(char(19), c1, 121) FROM Ian
GO

SELECT * FROM Ian
SELECT * FROM v_Ian

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

"Ian" <Ian_...@yahoo.com> wrote in message
news:10c744dd.01072...@posting.google.com...

0 new messages