sql2008 日期

Declare @Begindate Date;

set @Begindate = getdate()


Select
cast(Convert(varchar(10),cast(@Begindate as date),112) as int) As Datekey,
Year(@Begindate) As Year,
Datepart(Quarter,@Begindate) As Que,
Case
When Datepart(Quarter,@Begindate) = 1 Then ‘第一季度‘
When Datepart(Quarter,@Begindate) = 2 Then ‘第二季度‘
When Datepart(Quarter,@Begindate) = 3 Then ‘第三季度‘
Else ‘第四季度‘
End As QueCN,
Month(@Begindate) As Month,
Case
When Month(@Begindate) = 1 Then ‘一月‘
When Month(@Begindate) = 1 Then ‘二月‘
When Month(@Begindate) = 1 Then ‘三月‘
When Month(@Begindate) = 1 Then ‘四月‘
When Month(@Begindate) = 1 Then ‘五月‘
When Month(@Begindate) = 1 Then ‘六月‘
When Month(@Begindate) = 1 Then ‘七月‘
When Month(@Begindate) = 1 Then ‘八月‘
When Month(@Begindate) = 1 Then ‘九月‘
When Month(@Begindate) = 1 Then ‘十月‘
When Month(@Begindate) = 1 Then ‘十一月‘
Else ‘十二月‘
End As MonthCN,
Case
When Datepart(Day,@Begindate) <= 10 Then ‘1‘
When Datepart(Day,@Begindate) > 20 Then ‘3‘
Else ‘2‘
End As Ten,
Case
When Datepart(Day,@Begindate) <= 10 Then ‘上旬‘
When Datepart(Day,@Begindate) > 20 Then ‘下旬‘
Else ‘中旬‘
End As TenCN,
Datepart(Week,@Begindate) As Week,
Cast(Datepart(Week,@Begindate) As Char(2)) + ‘周‘ As WeekCN,
Datename(Weekday,@Begindate) As WeekDay,
Day(@Begindate) As Day,
Convert(Varchar(20),@Begindate,23) As DateTime

sql2008 日期

sql2008 日期

上一篇:C3P0数据库连接池使用


下一篇:sql performance Kill Lock