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)
 Formatting Time

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-06-30 : 10:15:17
How can i format time where there is a 0 in front of the time? I don't want military time. For example, if it's 7pm I want 07:00:00 PM. I just can't figure out how to keep that 0 in the front of time. Currently it just shows at 7:00:00 PM.

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-06-30 : 10:21:12
select stuff(right('0'+ltrim(right(CONVERT(varchar(20),getdate(),100),7)),7),6,0,' ')


--Ranjit
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-30 : 11:35:29
quote:
Originally posted by Brittney10

How can i format time where there is a 0 in front of the time? I don't want military time. For example, if it's 7pm I want 07:00:00 PM. I just can't figure out how to keep that 0 in the front of time. Currently it just shows at 7:00:00 PM.




First you should show us how you are getting the 7:00:00 PM.
Maybe then we can modify your code to get the desired result.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-04 : 10:57:45
If you use front end application, do the formation there

Madhivanan

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

- Advertisement -