By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,119 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,119 IT Pros & Developers. It's quick & easy.

Changind date formats

P: n/a
OKI
Hi.

I had a VB program that was using an SQL Server 6.5 DB. Date format
was dd/mm/yyyy. Now the DB was changed to an SQL Server 7 and the date
format is yyyy/mm/dd.

How can I do for changing date formats in the new DB to the old
format?

Im searching for a database level solution, not server level.

thanks
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
OKI (al***********@hotmail.com) writes:
I had a VB program that was using an SQL Server 6.5 DB. Date format
was dd/mm/yyyy. Now the DB was changed to an SQL Server 7 and the date
format is yyyy/mm/dd.

How can I do for changing date formats in the new DB to the old
format?

Im searching for a database level solution, not server level.


There are not really any date formats in databases in SQL Server. Dates
are stored as binary values, and ideally you program should communicate
with SQL Server using these binary values, and all conversions be
carried out the client, respecting the users regional settings.

If there is a need to control format in SQL Server code, you can use
the convert function, look it up in Books Online under Cast and Convert
for the full details. For instance, if you say:

SELECT convert(char(8), datecol, 112)

You get a datetime value on the form YYYYMMDD. If you say:

SELECT convert(datetime, @stringval, 121)

@stringval is interpreted according to format 121, which if memory
serves is YYYY-MM-DD HH:MM:SS.mmm.

If you just say:

SELECT @dateval = @stringval

there is an implicit conversion, which is carried out according to the
current datetime and language settings for the connection. There are
only one format i SQL7 that is always interpreted in the same way and
that is YYYYMMDD.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.