生成几个特殊的日期
SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0) AS 本年的第一天, DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0)) AS 本年最后一天, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()), 0) AS 本周的第一天, DATEADD(DAY, -1, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()) + 1, 0)) AS 本周的最后一天, DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()), 0) AS 本季度的第一天, DATEADD(DAY, -1, DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) + 1, 0)) AS 本季度最后一天, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) AS 本月的第一天, DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)) AS 本月最后一天;
posted on 2019-11-30 16:40 hold_on_up 阅读(184) 评论(0) 编辑 收藏 举报