sql server 时间
sql server 获取月份天数:1,SELECT 32-DAY(CAST('2015-03-01' as datetime)+32-DAY(CAST('2015-03-01' as datetime)))
2,SELECT 32-DAY(getdate()+32-DAY(getdate()))
3,select convert(char(10),dateadd(d,-1,dateadd(m,1,CAST('2015-02-01' as datetime))),120):2015-02-28
sql server 行列转换:
select [2015-02-01],[2015-02-02],[2015-02-04],[2015-02-05] from WR_WATER_C
pivot
(
sum(USEWATER) for [SPTIME] in([2015-02-01],[2015-02-02],[2015-02-04],[2015-02-05])
)tbl
--where SEQ=601
时间转换成年月:
select CONVERT(varchar(7),SPTIME,120) from WR_WATER_C