Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Change date time format and alias at same time

Author  Topic 

nto
Starting Member

12 Posts

Posted - 2009-07-28 : 21:14:49
Hi All,

just quick question i want to do select field with specific date time format (YY-MM-DD) and also want to rename the field at the same time.
is that possible in sql?
This is my code

SELECT
InstallationDT AS 'Installation Date'
WHERE
Maintenance

how do i output the installation date with different date format time?

Thanks for your time

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-28 : 22:20:28
the formatting should be performed at you client side where the date is being displayed not in SQL.

If you must, you can use convert() to convert the date to string and specify the format.

SELECT convert(varchar(10), InstallationDT, 121) AS 'Installation Date'


Do note that result data type is a string not a datetime anymore


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

nto
Starting Member

12 Posts

Posted - 2009-07-29 : 01:41:59
Thanks that work!!!!
Go to Top of Page
   

- Advertisement -