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 2008 Forums
 Transact-SQL (2008)
 Conver to Time format

Author  Topic 

hariharans87
Starting Member

6 Posts

Posted - 2011-07-25 : 04:09:07
I am using the code:

SELECT CONVERT(varchar(10),dtmTimeFrom,100) AS TimeFrom
FROM tblPosts


Result: 8:48AM

I want the result like: 8:48 AM
Space before AM and PM.

Thanks,
Hari.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-25 : 04:35:05
can't you format the TIME in your front end application ?


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

Go to Top of Page

eralper
Yak Posting Veteran

66 Posts

Posted - 2011-07-25 : 04:45:43
You can add a space using replace
REPLACE(REPLACE(@s, 'AM', ' AM'), 'PM', ' PM')


-------------
Eralper
http://www.kodyaz.com
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-07-25 : 04:50:28
SELECT STUFF(CONVERT(varchar(100),GETDATE(),100),18,0,' ')


--------------------------
http://connectsql.com/
Go to Top of Page

hariharans87
Starting Member

6 Posts

Posted - 2011-07-25 : 07:59:59
Thanks for your replies.
Go to Top of Page
   

- Advertisement -