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
 General SQL Server Forums
 New to SQL Server Programming
 Applying a Convert Statement on a column

Author  Topic 

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-07-08 : 13:50:12
I have this Query working:

select convert(VARCHAR(19),(Select TOP 1 Column1 FROM Table1), 20)
and outputting:
2005-09-14 01:31:52

Which is what I want. Now how can I make this convert expression convert a whole column?

Thanks,
Shijit

==========================
Pain is Weakness Leaving the Body.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-08 : 14:43:40
select convert(VARCHAR(19), Column1, 20)
from Table1

However, you should not be doing this in T-SQL. This is a presentation layer issue and should be done inside your application. Just because SQL supports this doesn't mean you should do it there.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-08 : 14:45:00
[code]SELECT CONVERT(VARCHAR(19),Column1, 20) FROM Table1[/code]

Go to Top of Page

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-07-08 : 15:00:30
Select CONVERT(VARCHAR(8),StartTime,108) AS HourMinuteSecond From Table

Did the trick and converted a datetime to just a time. Very similar to what both of u suggested.

Thanks so much ladies!

Dasman

==========================
Pain is Weakness Leaving the Body.
Go to Top of Page
   

- Advertisement -