tsql - time format in SQL Server -


does know how can format select statement datetime value display time in sql server?

example:

table cuatomer id   name   datetime 1    alvin  2010-10-15 15:12:54:00 2    ken    2010-10-08 09:23:56:00 

when select table result display below

id   name    time 1    alvin   3:12pm 2    ken     9:23am 

any way can in mssql?

you can use combination of convert, right , trim desired result:

select ltrim(right(convert(varchar(25), getdate(), 100), 7)) 

the 100 see in function specifies date format mon dd yyyy hh:miam (or pm), , there grab right characters.

you can see more converting datetimes here.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -