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
 Time Format

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2009-10-30 : 11:46:13
Hi All,

I have these values in Database of date & time which i am getting from Getdate(), now i have to convert this in below format
Current Value
2009-10-30 11:10:12.467
2009-10-30 11:10:12.467
2009-10-30 11:10:12.450
Should be Display
11:10 PM
11:10 PM
11:10 PM


please help me

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-30 : 11:51:09
Check out the date/time styles for CONVERT in SQL Server Books Online.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-30 : 12:25:39
select substring(convert(varchar(30),getdate(),100),13,5)+' '+right(convert(varchar(30),getdate(),100),2)

Jim

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-31 : 03:04:59
If you use front end application, do formation there. Otherwise

select stuff(right(convert(varchar(30),getdate(),0),7),6,0,' ')

Madhivanan

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

- Advertisement -