Reply to Re: Format a datetime columns output?

Your name:

Reply:


Posted by David Portas on 06/08/06 06:05

Erland Sommarskog wrote:
> CK (c_kettenbach@hotmail.com) writes:
> > Currently the query returns 2006-03-27 00:00:00, can I make it output
> > 03/27/2006, I want to truncate the time, and replace the hyphens with
> > forward slashes. Any ideas?
>
> To add to David's reply, if you are using Query Analyzer for output,
> you can change how dates are formatted under Tools->Options->Connections.
> Check "Use Regional Settings...".
>
> You can also do it in an SQL query, look up CASE and CONVERT in Books
> Online. But this is a really poor alternative. Date formatting should
> be handled by the client, so that the user's regional settings can be
> respected.
>

You can't actually format dates in a query at all. You can output a
string that looks like a date. I know you know this Erland, but the
difference is worth stating given that the application probably treats
dates and strings very differently.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация