------------ 获取系统时间 --------------
select GETDATE() as '当前日期时间',
DateName(year,GetDate())+'-'+DateName(month,GetDate())+'-'+DateName(day,GetDate()) as '当前日期',
DateName(quarter,GetDate()) as '第几季度',
DateName(week,GetDate()) as '一年中的第几周',
DateName(DAYOFYEAR,GetDate()) as '一年中的第几天',
DateName(year,GetDate()) as '年',
DateName(month,GetDate()) as '月',
DateName(day,GetDate()) as '日',
DateName(hour,GetDate()) as '时',
DateName(minute,GetDate()) as '分',
DateName(second,GetDate()) as '秒',
DateName(MILLISECOND,GetDate()) as '豪秒',
DateName(WEEKDAY,GetDate()) as '星期几'
------------ 获取表里面的时间 ---------------
select year(a.CreateDate) as 年, -- 使用 yesr() 函数获取年份
month(a.CreateDate) as 月, -- 使用 month() 获取月份
count(a.WorkcenterName) as 数量 -- 计算要统计的列,(总数太多,下面的group by 分组统计对应的月份的数量)
--要显示哪些内容:年,月,还有:以name名字相同的为一组,显示每组的数量
from dbo.Workcenter a -- 从哪个表里面
where year(a.CreateDate)=2017 -- 过滤:指定年份
group by year(a.CreateDate),month(a.CreateDate)
-- 需要进行分组的列
-- 将年相同分组以后,月再分组
Powered by ddoss.cn 12.0
©2015 - 2025 ddoss
渝公网安备50011302222260号
渝ICP备2024035333号
【实验平台安全承诺书】
小绿叶技术社区,优化网络中,点击查看配置信息
主机监控系统: 安全防火墙已开启检查cc攻击-下载文件完成后等待10s 恢复访问,检查连接数低于峰值恢复访问
您的IP:216.73.216.110,2025-12-01 16:08:25,Processed in 0.01006 second(s).