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)
 converting time question

Author  Topic 

phaze
Starting Member

42 Posts

Posted - 2010-03-09 : 10:55:43
how do i go about converting 2010-03-02 11:31:02.000 to 11:31am?

could someone show me an example?

phaze
Starting Member

42 Posts

Posted - 2010-03-09 : 11:56:50
ok a little bit more detail. the column of where my data is called is CallDate and it has this type of data in it 2010-03-02 11:27:20.000

I am wanting to convert that to just the time itself plus am or pm

11:27am

i currently did this but it's not giving me the option of having am or pm

select convert(char(5), CallDate, 108), CallDate
from dbo.OutboundIVR


(No column name) CallDate
11:27 2010-03-02 11:27:20.000
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-03-09 : 12:24:21
declare @date datetime
set @date = '2010-03-02 11:27:20.000'

select RIGHT(convert(varchar(50),@date,100),7)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-03-10 : 01:28:15
[General advice]

If you want to show formatted dates in front end application, do formation there

[/General advice]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

phaze
Starting Member

42 Posts

Posted - 2010-03-10 : 11:55:51
thank you for the help!
Go to Top of Page
   

- Advertisement -