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.
| Author |
Topic |
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2011-08-02 : 11:04:46
|
| I've nvarchar field with time data in it likeTable Name : ResultMastField Name : lTimeData :11:0011:3012:0012:3013:0013:30I've to show this time in 12 hour format with AM PM Clause like11:00 AM11:30 AM12:00 AM12:30 PM01:00 PM01:30 PMHow can I???VB6/ASP.NET------------------------http://www.nehasoftec.com |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-08-02 : 11:16:32
|
[code]Declare @t table ( id int identity(1,1), tm nvarchar(10))Insert Into @t Select '11:00'Insert Into @t Select '11:30'Insert Into @t Select '12:00'Insert Into @t Select '12:30'Insert Into @t Select '13:00'Insert Into @t Select '13:30'Select id, tm, right('0'+convert(varchar,CONVERT(time,tm),0),7)From @t[/code]Corey I Has Returned!! |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2011-08-02 : 11:52:46
|
quote: Originally posted by Seventhnight
Declare @t table ( id int identity(1,1), tm nvarchar(10))Insert Into @t Select '11:00'Insert Into @t Select '11:30'Insert Into @t Select '12:00'Insert Into @t Select '12:30'Insert Into @t Select '13:00'Insert Into @t Select '13:30'Select id, tm, right('0'+convert(varchar,CONVERT(time,tm),0),7)From @tCorey I Has Returned!!
Oh Gr8. It's working absolutely fine. But can u plz suggest me how to order it when i add order by tm then it shows me 1:00pm firstThanx againVB6/ASP.NET------------------------http://www.nehasoftec.com |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-08-02 : 14:34:40
|
[code]Select id, tm, right('0'+convert(varchar,CONVERT(time,tm),0),7)From @tOrder By CONVERT(time,tm)[/code]Corey I Has Returned!! |
 |
|
|
|
|
|
|
|