I am trying to port MySQL function DATE_FORMAT(date,'%y-%m-%d %h:%i:%s %p')
to MsSQL equivalent by using CONVERT()
.
How to format equivalent datetime string in SQL SERVER 2012 to give this output '2014-05-24 01:24:37 AM'
?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- How to truncate seconds in TSQL?
- Code for inserting data into SQL Server database u
- How to remove seconds from datetime?
- OLS with pandas: datetime index as predictor
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
In SQL Server 2012 and up you can use
FORMAT()
:In prior versions, you might need to concatenate two or more different datetime conversions to get what you need, for example:
See the Date and Time Styles section of CAST and CONVERT (Transact-SQL) for all of the built-in formatting styles.
I would keep in mind that unless you have a good reason for it, I mean a really good reason, formatting is usually a better job for the technology displaying the data.