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 |
tvb2727
Starting Member
35 Posts |
Posted - 2012-03-11 : 18:45:06
|
I want to show a column in Time format. How can I show the time like this: 12:12 PM? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
dosteroid
Starting Member
29 Posts |
Posted - 2012-03-12 : 05:50:59
|
You can replace the GetDate function with any datetime field to return the time portion of that field.SELECT substring(convert(varchar(20), GetDate(), 9), 13, 5)+ ' ' + substring(convert(varchar(30), GetDate(), 9), 25, 2) |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-12 : 10:06:50
|
quote: Originally posted by dosteroid You can replace the GetDate function with any datetime field to return the time portion of that field.SELECT substring(convert(varchar(20), GetDate(), 9), 13, 5)+ ' ' + substring(convert(varchar(30), GetDate(), 9), 25, 2)
only issue is you will face problems if you're trying to do some date manipulations with these converted values thereafter.So unless you've just using this for display, better not to do this.For display also its very easier to do formatting at your front end------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|