SQL Server 2012 Features

SQL SQL Server 2012 新增加的几个函数:

SELECT CONVERT (INT, 'Angkor-216.00') 直接报错

SELECT TRY_CONVERT(INT, 'SSD-216.00') 输出:NULL

SELECT TRY_CONVERT(INT, '216') 输出:416

SELECT TRY_CONVERT(DATETIME, '216')  输出:NULL

DECLARE @birthdate datetime = '2013-11-05'

Select FORMAT (@birthdate ,N'd') [Date],

FORMAT (@birthdate ,N'dd') [Date],

FORMAT (@birthdate ,N'ddd') [Date],

FORMAT (@birthdate ,N'dddd') [Date],
FORMAT (@birthdate ,N'dddd') [Date]

输出:

Date      Date   Date   Date   Date
11/5/2013   05   Tue   Tuesday   Tuesday

指定日期月份中的最后一天: 注意2月
SELECT EOMONTH ('02/02/2016') 'EOM Processing Date'

EOM Processing Date
2016-02-29

SELECT EOMONTH ( Getdate(), -1 ) AS 'Last Month'

Last Month
2013-10-31

SELECT CHOOSE ( 5, 'CTO', 'GM', 'DGM', 'AGM', 'Manager')
Output:Manager

SELECT CONCAT( 'Angkor','Joining Date at ', GETDATE());

Output:AngkorJoining Date at Nov 29 2013 2:23PM

上一篇:Javascript时间操作小结


下一篇:HTML字体及颜色设置